Skip to content
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
27 changes: 26 additions & 1 deletion src/bootstrap-tagsinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
itemText: function(item) {
return this.itemValue(item);
},
freeInput : true
freeInput : true,
limit : 0
};

function TagsInput(element, options) {
Expand All @@ -28,6 +29,7 @@
this.$input = $('<input size="1" type="text" />').appendTo(this.$container);

this.$element.after(this.$container);
this.enabled = true;

this.build(options);
}
Expand Down Expand Up @@ -95,6 +97,9 @@
if (!dontPushVal)
self.pushVal();

if (self.options.limit && self.itemsArray.length >= self.options.limit && self.isEnabled())
self.disable();

self.$element.trigger($.Event('itemAdded', { item: item }));
},

Expand All @@ -117,6 +122,9 @@
if (!dontPushVal)
self.pushVal();

if (self.options.limit && self.itemsArray.length < self.options.limit && !this.isEnabled())
this.enable();

self.$element.trigger($.Event('itemRemoved', { item: item }));
},

Expand All @@ -130,6 +138,9 @@
self.itemsArray.pop();

self.pushVal();

if (self.options.limit && !this.isEnabled())
this.enable();
},

refresh: function() {
Expand Down Expand Up @@ -308,6 +319,20 @@
}
},

disable: function() {
this.$input.prop('disabled', true);
this.enabled = false;
},

enable: function() {
this.$input.prop('disabled', false);
this.enabled = true;
},

isEnabled: function() {
return this.enabled;
},

destroy: function() {
var self = this;

Expand Down