Skip to content

Commit

Permalink
Merge pull request aehlke#19 from GUI/master
Browse files Browse the repository at this point in the history
Bind the tagSource callback to the tag-it context
  • Loading branch information
aehlke committed Aug 31, 2011
2 parents 21fda6e + 565a6e4 commit 00d7a4a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/tag-it.js
Expand Up @@ -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')
Expand Down

0 comments on commit 00d7a4a

Please sign in to comment.