Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Open
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
13 changes: 10 additions & 3 deletions js/bootstrap-tokenfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
, getInput: function() {
return this.$input.val()
}

, setInput: function (val) {
if (this.$input.hasClass('tt-input')) {
// Typeahead acts weird when simply setting input value to empty,
Expand Down Expand Up @@ -653,7 +653,13 @@
return // No input, simply return

var tokensBefore = this.getTokensList()
this.setTokens( this.$input.val(), true )
var tokenData = {
label: this.$input.val(),
value: this.$input.val()
}
if (this.$input.data('attrs') != null)
tokenData = $.extend({}, this.$input.data('attrs'), tokenData)
this.setTokens( [tokenData], true )

if (tokensBefore == this.getTokensList() && this.$input.val().length)
return false // No tokens were added, do nothing (prevent form submit)
Expand Down Expand Up @@ -790,6 +796,7 @@
this.preventCreateTokens = true

this.$input.val( attrs.value )
.data('attrs', attrs)
.select()
.data( 'edit', true )
.width( tokenWidth )
Expand Down Expand Up @@ -893,7 +900,7 @@
else {
//temporary reset width to minimal value to get proper results
this.$input.width(this.options.minWidth);

var w = (this.textDirection === 'rtl')
? this.$input.offset().left + this.$input.outerWidth() - this.$wrapper.offset().left - parseInt(this.$wrapper.css('padding-left'), 10) - inputPadding - 1
: this.$wrapper.offset().left + this.$wrapper.width() + parseInt(this.$wrapper.css('padding-left'), 10) - this.$input.offset().left - inputPadding;
Expand Down