Skip to content

Commit

Permalink
Filter out non-typeahead elements for plugin methods. Fixes #815.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Harding committed Jul 8, 2014
1 parent c20a7ec commit af0cf7b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/typeahead/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@
};

$.fn.typeahead = function(method) {
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
var tts;

// methods that should only act on intialized typeaheads
if (methods[method] && method !== 'initialize') {
// filter out non-typeahead inputs
tts = this.filter(function() { return !!$(this).data(typeaheadKey); });
return methods[method].apply(tts, [].slice.call(arguments, 1));
}

else {
Expand Down

0 comments on commit af0cf7b

Please sign in to comment.