jquery ui 手风琴禁用点击
我有一个像这样的手风琴集
$(".accordion-form").accordion({
collapsible:false,
autoHeight: false,
changestart: checkChanged,
change: function(e, ui) {active = $( ".accordion-form" ).accordion( "option", "active");},
active: 0
});
active 是一个静态变量,它始终具有活动内容。
我想做的是在活动标题之前启用标题以供单击,并在活动标题之后禁用标题以供单击。
这样我就可以让手风琴表现得像一种形式,“你可以后退,但在完成这部分之前不能前进”。
任何帮助将不胜感激
I have an accordion set like this
$(".accordion-form").accordion({
collapsible:false,
autoHeight: false,
changestart: checkChanged,
change: function(e, ui) {active = $( ".accordion-form" ).accordion( "option", "active");},
active: 0
});
active is a static variable which always have the active content.
What I would like to do is enable headers before the one actived for clicking, and the headers after the active one been disabled for clicking.
This way I can make the accordion act like a form in the way of "you can go back but no forward til your finish this part".
Any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我同意 Frédéric 的观点,即手风琴对于这种行为来说并不是一个很好的小部件,但您应该能够使用一些简单的 JS 来做到这一点。将另一个“onclick”处理程序附加到手风琴标头,并在标头距离太远时终止该事件:
这需要您有一个
current_section
变量来保存最后一个已完成的部分(我假设您已经有类似的东西),并确保该处理程序在 JqueryUI 手风琴设置之后(或之前)附加,以便您的处理程序首先被调用。希望这有帮助!
While I agree with Frédéric that an accordion isn't a great widget for this sort of behaviour, you should be able to do it with some simple JS. Attach another 'onclick' handler to the accordion headers, and have it kill the event if the header was too far along:
That'll need you to have a
current_section
variable that holds the last section completed (I assume you already have something like this), and make sure this handler gets attached after (or before) the JqueryUI accordion setup, so your handler gets called first.Hope this helps!
我在其他地方找到了这个问题的解决方案:
现在实现禁用功能的技巧:
每当您想重新激活选项卡时,请执行以下操作:
来源:https://forum.jquery.com/topic/disable-enable-sections-of-accordion
I found the solution to this problem elsewhere:
Now the hack to implement the disabling functionality:
Whenever you want to re-activate a tab, do:
Source: https://forum.jquery.com/topic/disable-enable-sections-of-accordion