Permalink
Browse files

Merge pull request #19 from GUI/master

Bind the tagSource callback to the tag-it context
  • Loading branch information...
2 parents 21fda6e + 565a6e4 commit 00d7a4aa8a22b2aa3353fb25d6cd7efbc5961dc9 @aehlke aehlke committed Aug 31, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 js/tag-it.js
View
@@ -103,14 +103,19 @@
this.options.tagSource = this.options.tagSource || function(search, showChoices) {
var filter = search.term.toLowerCase();
- var choices = $.grep(that.options.availableTags, function(element) {
+ var choices = $.grep(this.options.availableTags, function(element) {
// Only match autocomplete options that begin with the search term.
// (Case insensitive.)
return (element.toLowerCase().indexOf(filter) === 0);
});
- showChoices(that._subtractArray(choices, that.assignedTags()));
+ showChoices(this._subtractArray(choices, this.assignedTags()));
};
+ // Bind tagSource callback functions to this context.
+ if ($.isFunction(this.options.tagSource)) {
+ this.options.tagSource = $.proxy(this.options.tagSource, this);
+ }
+
this.tagList
.addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all')

0 comments on commit 00d7a4a

Please sign in to comment.