Skip to content

Instantly share code, notes, and snippets.

@bjrnqprs
Last active December 19, 2015 00:29
Show Gist options
  • Save bjrnqprs/5868920 to your computer and use it in GitHub Desktop.
Save bjrnqprs/5868920 to your computer and use it in GitHub Desktop.
Extend Typeahead (Twitter Bootstrap) with an onshow function. When initializing Typeahead, allows for defining onshow: function() {}.
(function($) {
if($.fn.typeahead != 'undefined') {
var _show = $.fn.typeahead.Constructor.prototype.show;
$.fn.typeahead.Constructor.prototype.show = function() {
if(typeof this.options.onshow == 'function') {
this.options.onshow();
}
// Call parent
_show.apply(this, []);
};
}
}(window.jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment