简体   繁体   English

jQuery bootstrap-switch 3.0.2不会在输入上触发更改事件

[英]jQuery bootstrap-switch 3.0.2 is not triggering change event on the input

I've just updated the jQuery bootstrap-switch plugin to the latest version that includes so many interesting and cool features, but I'd a working code that looks like: 我刚刚将jQuery Bootstrap-Switch插件更新为最新版本,其中包括许多有趣而酷炫的功能,但我的工作代码如下:

var $checkbox = $('input[name="whatever"]');

$checkbox.bootstrapSwitch();

$checkbox.on('change', function() {
  // ... do something cool here
});

And when I toggle the switch a change event was being triggered in the input, cool because the above code works if so, but... with the last update this is not happening! 当我切换开关时,输入中触发了change事件,很酷,因为上面的代码可以正常工作,但是...在最近一次更新中,这没有发生!

I know there are an onSwitchChange callback that I can use to identify changes on the input but you know I don't want to refactor 100 lines of code before knowing if I'm missing something. 我知道有一个onSwitchChange回调可用于识别输入上的更改,但是您知道在不知道是否缺少某些内容之前,我不想重构100行代码。

This has worked for me. 这对我有用。 Version 3.0.2 版本3.0.2

        $elem.on('switchChange.bootstrapSwitch', function (e, data) {
          //Do something
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM