如何在 jquery ui 微调器中使用两个停止事件

how to use two stop event in jquery ui spinner

在下面的代码中,我需要执行带有去抖动(延迟)的 show_error 方法和没有延迟的 show_value 方法。

这两种方法都只需要在stop事件中怎么办?

$("#test").spinner({
 stop: function(event , ui){
 show_value();
  },
 stop: _.debounce(function(e, ui) {
      show_error();

    }, 300)
        });

在单个处理程序中调用两个函数:

var debouncedStop = _.debounce(function(e, ui) {
      show_error();
}, 300);
$("#test").spinner({
 stop: function(event, ui){
     show_value();
     debouncedStop();
 }
});

或者分别绑定:

$("#test").spinner()
          .on("spinstop", function(event , ui) {
              show_value();
          })
          .on("spinstop", _.debounce(function(e, ui) {
              show_error();
          }, 300));