Before flagging this question as duplicate please note I've checked out all of these links and none work with the latest version v0.11.1:
My typeahed contains a form with an input. I need to not to close the dropdown when user click a suggestion.
Is there a reliable way to prevent close? The obvious way it's not working ( https://jsfiddle.net/gcgdqfxp/ ):
$('.typeahed').on('typeahead:select', function (event, obj) {
// not working
event.preventDefault();
// not working
return false;
});
typeahead:select – Fired when a suggestion is selected. The event handler will be invoked with 2 arguments: the jQuery event object and the suggestion object that was selected.
Yeah!!! Found a solution looking at the source here the (undocumented) "typeahead:beforeselect" event is triggered before actually trigger the "typeahead:select", so it's easy to stop propagation ( https://jsfiddle.net/gcgdqfxp/2/ ) like:
$('.typeahead').bind('typeahead:beforeselect', function (event) {
event.preventDefault();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.