简体   繁体   English

Bootstrap在弹出窗口中提前输入

[英]Bootstrap typeahead in a popover

I am trying to implement bootstrap's typeahead but I am trying to have the input bar appear on a popover when a button is click. 我正在尝试实现bootstrap的预输入,但是当单击按钮时,我试图使输入栏出现在弹出窗口上。

Pretty much have a typeahead functionality inside a 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>

Adding the JS: 添加JS:

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

The typeahead doesnt seem to work in the popover however. 但是,预输入似乎在弹出窗口中不起作用。 If I remove the class=hide part, the unhidden input works but not the one in the popover. 如果删除class = hide部分,则未隐藏的输入有效,但弹窗中的输入无效。

Wondering if anyone has ran into this? 想知道是否有人遇到过这个吗?

Any help would be great! 任何帮助将是巨大的!

did you try this? 你有尝试过吗?

// 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...

})

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

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