简体   繁体   English

Bootstrap数据切换不适用于ember组件

[英]Bootstrap data-toggle doesn't work with ember component

I have a jquery plugin that creates following html 我有一个jQuery插件,可以创建以下HTML

<div class="panel-heading">
  <h4 class="">
    <a data-toggle="collapse" href="#collapse2" class="collapsible-title display-inline full-width bold">Select Gigs</a>
  </h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
  <div class="panel-body">
    <div class="row">
      <div class="col-xs-12">
        <input type="text" class="input-text-field margin-medium-bottom" placeholder="Search" />
      </div>
    </div>
...... and some other divs here .....

I want to toggle div with id collapse2 when click on <a></a> above it. 当我单击其上方的<a></a>时,我想切换ID为collapse2 div。 It works fine if I add the html inside hbs file. 如果我在hbs文件中添加html,效果很好。 But when I create above html inside jquery and insert into the DOM as follows it change the url to domain/#collapse2 但是当我在jquery中创建以上html并按如下方式插入DOM时,它将url更改为domain/#collapse2

    _initializeAutoComplete: function () {
        Ember.$('#' + this.get('divId')).setAutocomplete({
            data: this.get('dataTree'),
            multiSelect: true,
            selectingType: 3
        });

    }.on('didInsertElement')
});

How can I make the toggling work without ember going to href as a url change? 如何在不将href用作url更改的情况下进行切换? Appreciate any help. 感谢任何帮助。

Move the bootstrap attributes to the div above (or h4 or create new as your need) 将引导程序属性移到上面的div(或h4或根据需要创建新属性)

<div class="panel-heading" data-toggle="collapse" href="#collapse2" class="collapsible-title display-inline full-width bold">
  <h4 class="">
    <a href="#">Select Gigs</a>
  </h4>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM