Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Disable requireAutocommit when no autocommit source

  • Loading branch information...
commit b73d67002d10a3eda66c9abb8e0d76469457b16a 1 parent 9ddc900
@cleishm authored
Showing with 17 additions and 10 deletions.
  1. +17 −10 js/tag-it.js
View
27 js/tag-it.js
@@ -102,21 +102,28 @@
this._tagInput.attr('tabindex', this.options.tabIndex);
}
- this.options.tagSource = this.options.tagSource || function(search, showChoices) {
- var filter = search.term.toLowerCase();
- 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(this._subtractArray(choices, this.assignedTags()));
- };
+ if (!this.options.tagSource && this.options.availableTags.length > 0) {
+ this.options.tagSource = function(search, showChoices) {
+ var filter = search.term.toLowerCase();
+ var choices = $.grep(that.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, this.assignedTags()));
+ };
+ }
// Bind tagSource callback functions to this context.
if ($.isFunction(this.options.tagSource)) {
this.options.tagSource = $.proxy(this.options.tagSource, this);
}
+ // cannot require autocomplete without an autocomplete source
+ if (!this.options.tagSource) {
+ this.options.requireAutocomplete = false;
+ }
+
this.tagList
.addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all')
@@ -217,7 +224,7 @@
}
// Autocomplete.
- if (this.options.availableTags || this.options.tagSource) {
+ if (this.options.tagSource) {
this._tagInput.autocomplete({
source: this.options.tagSource,
select: function(event, ui) {
Please sign in to comment.
Something went wrong with that request. Please try again.