From 914bca95c2e1950fc3e9a39cd679361db58c192c Mon Sep 17 00:00:00 2001 From: Johann Reyes Date: Tue, 29 Oct 2013 10:11:17 -0400 Subject: [PATCH] Add support for placeholder --- src/bootstrap-tagsinput.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bootstrap-tagsinput.js b/src/bootstrap-tagsinput.js index 392a1103..337b98af 100644 --- a/src/bootstrap-tagsinput.js +++ b/src/bootstrap-tagsinput.js @@ -31,9 +31,11 @@ this.isSelect = (element.tagName === 'SELECT'); this.multiple = (this.isSelect && element.hasAttribute('multiple')); this.objectItems = options && options.itemValue; + this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : ''; + this.inputSize = Math.max(1, this.placeholderText.length); this.$container = $('
'); - this.$input = $('').appendTo(this.$container); + this.$input = $('').appendTo(this.$container); this.$element.after(this.$container); @@ -343,7 +345,7 @@ } // Reset internal input's size - $input.attr('size', Math.max(1, $input.val().length)); + $input.attr('size', Math.max(this.inputSize, $input.val().length)); }, self)); // Remove icon clicked