From 453e1139fb05fd72bc8c244a220b1834ceb2541d Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Wed, 17 Aug 2011 20:31:34 -0600 Subject: [PATCH] Bind the tagSource callback to the tag-it context. This allows custom callbacks to access tag-it functions, such as assignedTags(), like the default callback does. --- js/tag-it.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/tag-it.js b/js/tag-it.js index f08a52f0..fff12423 100644 --- a/js/tag-it.js +++ b/js/tag-it.js @@ -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')