Skip to content

Commit

Permalink
Bind the tagSource callback to the tag-it context. This allows custom…
Browse files Browse the repository at this point in the history
… callbacks to access tag-it functions, such as assignedTags(), like the default callback does.
  • Loading branch information
GUI committed Aug 18, 2011
1 parent 440b9b7 commit 453e113
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/tag-it.js
Expand Up @@ -103,13 +103,14 @@

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()));
};
this.options.tagSource = $.proxy(this.options.tagSource, this);

this.tagList
.addClass('tagit')
Expand Down

0 comments on commit 453e113

Please sign in to comment.