Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bind the tagSource callback to the tag-it context #19

Merged
merged 2 commits into from Aug 31, 2011
Jump to file or symbol
Failed to load files and symbols.
+7 −2
Split
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')