mirror of
https://github.com/zhigang1992/bootstrap-tokenfield.git
synced 2026-04-29 04:15:44 +08:00
Provide an unedit method. Fixes #8
This commit is contained in:
40
bootstrap-tokenfield/bootstrap-tokenfield.js
vendored
40
bootstrap-tokenfield/bootstrap-tokenfield.js
vendored
@@ -262,6 +262,9 @@
|
||||
.on('autocompleteselect', function (e, ui) {
|
||||
_self.$input.val('')
|
||||
_self.createToken( ui.item )
|
||||
if (_self.$input.data( 'edit' )) {
|
||||
_self.unedit(true)
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
@@ -469,23 +472,7 @@
|
||||
this.$input.val('')
|
||||
|
||||
if (this.$input.data( 'edit' )) {
|
||||
|
||||
this.$input
|
||||
.appendTo( this.$wrapper )
|
||||
.data( 'edit', false )
|
||||
//.css( 'width', this.options.minWidth + 'px' )
|
||||
|
||||
// Because moving the input element around in DOM
|
||||
// will cause it to lose focus, we provide an option
|
||||
// to re-focus the input after appending it to the wrapper
|
||||
if (focus) {
|
||||
var _self = this
|
||||
setTimeout(function () {
|
||||
_self.$input.focus()
|
||||
}, 1)
|
||||
}
|
||||
|
||||
//this.$wrapper.css( 'width', this.$wrapper.data('prev-width') )
|
||||
this.unedit(focus)
|
||||
}
|
||||
|
||||
e.preventDefault()
|
||||
@@ -624,6 +611,25 @@
|
||||
.width( tokenWidth )
|
||||
}
|
||||
|
||||
, unedit: function (focus) {
|
||||
this.$input
|
||||
.appendTo( this.$wrapper )
|
||||
.data( 'edit', false )
|
||||
//.css( 'width', this.options.minWidth + 'px' )
|
||||
|
||||
// Because moving the input element around in DOM
|
||||
// will cause it to lose focus, we provide an option
|
||||
// to re-focus the input after appending it to the wrapper
|
||||
if (focus) {
|
||||
var _self = this
|
||||
setTimeout(function () {
|
||||
_self.$input.focus()
|
||||
}, 1)
|
||||
}
|
||||
|
||||
//this.$wrapper.css( 'width', this.$wrapper.data('prev-width') )
|
||||
}
|
||||
|
||||
, remove: function (e, direction) {
|
||||
if (this.$input.is(':focus') || this.disabled) return
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user