Creating a tag using jQuery bootstrap-tagsinput without hitting the enter key [closed]

寵の児 提交于 2020-02-05 03:57:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!