Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions js/tag-it.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -103,14 +103,19 @@


this.options.tagSource = this.options.tagSource || function(search, showChoices) { this.options.tagSource = this.options.tagSource || function(search, showChoices) {
var filter = search.term.toLowerCase(); 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. // Only match autocomplete options that begin with the search term.
// (Case insensitive.) // (Case insensitive.)
return (element.toLowerCase().indexOf(filter) === 0); 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 this.tagList
.addClass('tagit') .addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all') .addClass('ui-widget ui-widget-content ui-corner-all')
Expand Down