【问题标题】:jquery steps add listener to the next buttonjquery 步骤将监听器添加到下一个按钮
【发布时间】:2017-01-16 22:41:19
【问题描述】:

在 jquery 步骤中,当用户单击下一步时,我想确保所有所需的空白都已填满,否则会弹出警报。 例如,一个步骤中有6个复选框,用户需要至少选择一个,如何将事件监听器添加到下一个按钮?

【问题讨论】:

  • 请将您的代码添加到问题中。

标签: jquery jquery-steps


【解决方案1】:

请查看事件部分here。有onStepChanging事件。

所以你可以像这样添加事件监听器:

$("#example").steps({
    // options
    // ...
    onStepChanging: function (event, currentIndex, newIndex) {
        if (!validate()) {
            // alert and stop when some validation failed
            alert("Error");
            return false;
        } else {
            // proceed
            return true; 
        }
    }
});

【讨论】:

  • 太棒了!另外:如果您只想处理点击下一个按钮,您可以在onStepChanging 函数中检查if (newIndex > currentIndex) { // do something }
猜你喜欢
  • 2019-09-06
  • 2014-01-10
  • 1970-01-01
  • 2012-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多