Using Polymer 2.0 with Bootstrap JS

觀看次數:461 次
跳至第一則未讀訊息

Andrii La

未讀,
2017年6月28日 上午10:17:3328/6/2017
收件者︰ Polymer

Hi.

I need to use Polymer 2.0 (for creating Web components), and Bootstrap (as a framework for styling). I've created simple web component and added dropdown element into it:

<dom-module id="my-component">
  <template>
    <link rel="stylesheet" type="text/css" 
      href="../bower_components/bootstrap/dist/css/bootstrap.css">

    <div class="dropdown">
      <button class="btn btn-primary dropdown-toggle" type="button" 
          data-toggle="dropdown" id="dropTest">Dropdown Example
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li><a href="#">Item1</a></li>
        <li><a href="#">Item2</a></li>
        <li><a href="#">Item3</a></li>
      </ul>
    </div>
  </template>

  <script>
    class MyComponent extends Polymer.Element {
      static get is() { return 'my-component' }

      constructor() {
        super();
      }
    }

    customElements.define(MyComponent.is, MyComponent);       
  </script>
</dom-module>

But, when I click on dropdown it is not working correctly. I can see that Bootstrap's styles are being applied, but dropdown doesn't expand.

I think it could be because Polymer uses Shadow DOM, and Bootstrap JS cannot use it.

Bootstrap CSS works. But my main problem is Bootstrap JS doesn't work. Is it possible to use Bootstrap JS with Polymer, despite on Shadow DOM? – 

Could anyone please clarify how to correctly use Polymer and Bootstrap together?

Thank you in advance.

joesim...@gmail.com

未讀,
2017年12月11日 上午9:04:2111/12/2017
收件者︰ Polymer
Hi Andrii,
This is my problem also. Did you find a solution for this so far?

anilk...@gmail.com

未讀,
2019年4月30日 上午12:36:1330/4/2019
收件者︰ Polymer
Hi, 

Can you please share the solution if you figured out a way to get bootstrap js working with Polymer?
回覆所有人
回覆作者
轉寄
0 則新訊息