加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – 如何使用选择的bootstrap popover?

发布时间:2020-12-17 21:26:00 所属栏目:安全 来源:网络整理
导读:使用Meteor在Popover中使用Chosen的最佳方法是什么? 我有一个日历,当我点击事件时,弹出一个带有小表格的popover来更新事件. 这是我的模板日历: template name="bookingCalendar" section div class="col-md-12" div id="calendarMain"/div /div /section {
使用Meteor在Popover中使用Chosen的最佳方法是什么?

我有一个日历,当我点击事件时,弹出一个带有小表格的popover来更新事件.

这是我的模板日历:

<template name="bookingCalendar">
  <section>
    <div class="col-md-12">
      <div id="calendarMain"></div>
    </div>
  </section>

  {{> bookingCalendar_popover}}
</template>

我的popover模板:

<template name="bookingCalendar_popover">
  <div id="bookingCalendar_popover" style="display: none">
    <form class="form-horizontal" role="form">
      <div class="col-md-12 col-lg-6">
        {{> objectIndividual_edit id = 'individual' label = 'Patient'}}
      </div>
    </form>
  </div>
</template>

我的目标是:

<template name="objectIndividual_edit">
  <div class="objectRow">
    {{> objectLabel label=label id=id}}
    <div class="objectEdit">
      <select id="{{id}}" name="{{id}}" class="form-control objectIndividual">
        <option value="0"></option>
        {{#each individuals}}
          <option value="{{_id}}">{{firstName}} {{lastName}}</option>
        {{/each}}
      </select>
    </div>
  </div>
</template>

我打开我的popover

Template.bookingCalendar.rendered

我在这里初选.

Template.objectIndividual_edit.rendered = function() {
  var input = $('.objectIndividual');
  input.chosen({disable_search_threshold: 10});
};

Template.objectIndividual_edit.helpers({
  individuals: function(){
    return Individual.find({deactivatedAt: {$exists: false}},{sort: {firstName: 1,lastName: 1}});
  }
});

如果没有选择,则正确填充选择.但是当我选择使用时,选择被打破了.

那么,任何人都有一个想法或一个例子来做到这一点?

解决方法

与 chosen with bootstrap 3 not working properly类似,在内容准备好后需要初始化所选行为.与模态事件类似,您可以使用popover事件:

$('#thing').popover(
  // content,title,etc...
).on('shown.bs.popover',function () {
  $('.chosen-select').chosen();
}).on('hidden.bs.popover',function () {
  // Destroy when the popover is hidden otherwise it does not work if the popover is re-opened. 
  $('.chosen-select').chosen('destroy');
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读