清除select2而不触发更改事件 [英] Clear select2 without triggering change event

查看:458
本文介绍了清除select2而不触发更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在使用的select2输入,在更改"时,我正在获取值并执行操作.我试图清除select2而不触发更改事件.这可能吗?

I have a select2 input that I'm using and on 'change' I'm grabbing the values and performing an action. I'm trying to clear that select2 without triggering a change event. Is this possible?

要清除select2,我正在使用以下代码:

To clear the select2 I'm using the following code:

$docInput.select2('data', null);

这将根据需要清除输入,但还会触发更改事件,该更改事件贯穿我的其他代码.必须有一种使触发器静音的方法.有什么想法吗?

This clears the input as desired, but also triggers a change event which runs through my other code. There must be a way to silence the trigger. Any ideas?

推荐答案

我相信您所需要的只是:

I believe all you need is:

$docInput.select2('data', null, false);

这篇关于清除select2而不触发更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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