简体   繁体   English

Twitter Typeahead无法与Bootstrap CSS一起使用

[英]Twitter Typeahead not working with Bootstrap CSS

I can't manage to make this bootply work. 我无法使此启动工作。 It consists of a bootstrap modal with a form containing two input fields in which I'd like to use typeahead. 它包含一个引导程序模态,其形式为包含两个输入字段的表单,我想在其中使用typeahead。 the second input field is also based on bootstrap-tagsinput which means the typeahead should aid in finding tags. 第二个输入字段也是基于bootstrap-tagsinput的,这意味着输入应该有助于查找标签。

http://www.bootply.com/QdjImYdrJY http://www.bootply.com/QdjImYdrJY

I forked your bootply and made it to work : http://www.bootply.com/5tVniXhbBg 我分叉了您的bootply,并使其正常工作: http : //www.bootply.com/5tVniXhbBg

You had two issues : 您有两个问题:

  • First one, your scripts load asynchronously, so you have to wait for them to be loaded to use their functions (ie tagsinput and typeahead) 首先,您的脚本是异步加载的,因此您必须等待它们被加载才能使用其功能(例如,tagsinput和typeahead)

    $.getScript( 'myscript' , function () { // Callback function, // Here you can use what the script you loaded provides. } );

  • Second one, you don't have to put the data-role="tagsinput" manually, it will be added by the plugin. 第二个,您不必手动放置data-role="tagsinput" ,它将由插件添加。 If you specify it, the plugin won't process it as it thinks it already processed it! 如果您指定它,则插件将不会处理它,因为它认为它已经处理了它!

Hope this helps, 希望这可以帮助,

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

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