弹出窗口中的Bootstrap typeahead

时间:2014-09-04 21:53:16

标签: javascript jquery twitter-bootstrap-3 typeahead.js

我正在尝试实现bootstrap的typeahead,但是当点击一个按钮时,我试图让输入栏显示在弹出框中。

在popover中几乎有一个预先输入功能。

<div id="popover-button-container">
    <button id="popover-button" type="button" class="btn btn-default" 
            data-toggle="popover"
            data-placement="left">${entries.size() - 4} more</button>
            <div id="popover-content" class="hide">
                <input class="typeahead" type="text" placeholder="Search by Artist Name" />
            </div>
</div>

添加JS:

<script>
$("#popover-button").popover({
    html:true,
    content: function(){
        return $('#popover-content').html();
    }
})</script>

然而,先行者似乎并不适用于弹出窗口。如果我删除了class = hide部分,则取消隐藏的输入可以正常工作,但不能使用popover中的输入。

想知道是否有人碰到过这个?

任何帮助都会很棒!

1 个答案:

答案 0 :(得分:0)

你试过这个吗?

// Constructs the suggestion engine
// Typehead codes here

$('#myPopover').on('show.bs.popover', function () {

  // Initialize your typehead script
  typehead.initilize();

  // Followed by your Typehead codes here...

})
相关问题