如何取消手风琴控件的更改事件 [英] How to cancel change event for accordion controls

查看:82
本文介绍了如何取消手风琴控件的更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$("#accordion").accordion({
    change: function (event, ui) {
        alert('event have to be changed')
    },
    changestart: function (event, ui) {
       return false;
    }
});

是否可以取消更改事件?

Is it possible to cancel the change event?

推荐答案

stopPropagation()是停止处理jQueryUI操作的关键,但必须在changestart事件之前中断。例如,当实际点击标题项时。

stopPropagation() is the key to stopping a jQueryUI action from processing, but it must be interrupted BEFORE the changestart event. For example, when the header item is actually clicked.

如果这是您的手风琴中的标题/内容对:

If this is a header/content pair in your accordion:

<h3 class='noexpand'>This is a dummy header</h3>
<div>This is dummy content</div>

然后这会阻止手风琴在点击标题时展开div:

Then this will prevent the accordion from expanding the div when the header is clicked:

$("h3.noexpand").click(function(e) {
    e.stopPropagation();
});

参见 jquery accordion阻止冒泡/允许默认链接操作

这篇关于如何取消手风琴控件的更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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