使用jquery bootstrap-tagsinput创建标记而不按Enter键 [英] creating a tag using jquery bootstrap-tagsinput without hitting the enter key

查看:422
本文介绍了使用jquery bootstrap-tagsinput创建标记而不按Enter键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery bootstrap-tagsinput ,目前创建标签的唯一方法是在输入后点击回车键。我要找的是更多简单的用户创建标签的方法。我以为我可以在 bootstrap-tagsinput.js 文件中的某个地方做一个 onblur

im 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.

有人可以协助吗?

bootstrap tagsinput

谢谢。

推荐答案

您可以修改插件本身(bootstratp-tagsinput.js)并添加模糊事件(我几乎从keydown事件中复制了这个):

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));

这篇关于使用jquery bootstrap-tagsinput创建标记而不按Enter键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆