Search code examples
javascriptcsstwitter-bootstrapbootstrap-typeahead

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. the second input field is also based on bootstrap-tagsinput which means the typeahead should aid in finding tags.

http://www.bootply.com/QdjImYdrJY


Solution

  • I forked your bootply and made it to work : 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 (i.e tagsinput and 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. If you specify it, the plugin won't process it as it thinks it already processed it!

    Hope this helps,