Last active
December 19, 2015 00:29
-
-
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() {}.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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