Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Typeahead Escaping?

So I'm using the Bootstrap typeahead plugin to display a list of classes. It works fine for most courses, but if you click the dropdown for Driver's Education, the text displays in the input field as "Driver's Education".

Is there some way to fix this?

like image 725
kennysong Avatar asked Mar 11 '26 05:03

kennysong


1 Answers

It is because you define your source array as a data attribute, and therefore is interpreted with HTML-entities. To the opposit, when the options is defined in a javascript handler special chars as ' will show up normal when the list dropdowns and afterwards in the input field when you have clicked :

HTML wthout data attributes :

<input type="text" data-provide="typeahead" id="stackoverflow">

jquery constructer instead :

$("#stackoverflow").typeahead({
   "source" : ["Driver's Education", "Toys'r'us Education"] //and so on
   //(,) rest of options, if any
});
like image 94
davidkonrad Avatar answered Mar 12 '26 19:03

davidkonrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!