Skip to content

Commit

Permalink
Merge pull request #43 from jreyes/placeholder-support
Browse files Browse the repository at this point in the history
Add support for placeholder
  • Loading branch information
timschlechter committed Oct 30, 2013
2 parents dd5523c + 914bca9 commit 090aa87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bootstrap-tagsinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div class="bootstrap-tagsinput"></div>');
this.$input = $('<input size="1" type="text" />').appendTo(this.$container);
this.$input = $('<input size="' + this.inputSize + '" type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);

this.$element.after(this.$container);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 090aa87

Please sign in to comment.