问题
I'm using jquery bootstrap-tagsinput
and currently the only method for creating a tag is by hitting the enter key after typing it in. What I am looking for is a more easy user method of creating the tags. I was thinking that I could do an onblur
somewhere in the bootstrap-tagsinput.js
file.
Can someone assist?
bootstrap tagsinput
回答1:
You can modify the plugin itself (bootstratp-tagsinput.js) and add on blur event (I pretty much copied this one from on keydown event):
self.$container.on('blur', 'input', $.proxy(function(event) {
var $input = $(event.target);
if (self.options.freeInput) {
self.add($input.val());
$input.val('');
event.preventDefault();
}
// Reset internal input's size
$input.attr('size', Math.max(this.inputSize, $input.val().length));
}, self));
来源:https://stackoverflow.com/questions/24355448/creating-a-tag-using-jquery-bootstrap-tagsinput-without-hitting-the-enter-key