简体   繁体   English

jQuery UI手风琴-启用一些面板

[英]jQuery UI Accordion - enable some panels

I've got this kind of wizard. 我有这种向导。 I wish it to be openable only the panels upwards (to turn back) and not those downwards. 我希望它只能向上打开(向后翻转)面板,而不能向下打开。

For example: I am filling out the step1, go to step 2, I can not be able to jump to step 4 or 5, but I have to be able to go back to step 1 例如:我正在填写步骤1,转到步骤2,我无法跳到步骤4或5,但是我必须能够回到步骤1

This is my code: 这是我的代码:

<div id="accordion">
<h3>Step 1</h3>
<div id="img_divisione">
    <a href="">Something</a>
</div>
<h3>Step 2</h3>
<div>
    <a href="">Something</a>
</div>
<h3>Step 3</h3>
<div>
    <a href="">Something</a>
</div>
<h3>Step 4</h3>
<div>
    <a href="">Something</a>
</div>

$(document).ready(function() {
$("#img_divisione a").click(function() {
   $("#accordion").accordion( "option", "active", 1 );
});
});

$(function() {
   $( "#accordion" ).accordion({
        heightStyle: "content"
});
});   

Have a look at the 看看

beforeActivate: function( event, ui ) {}

event of jQuery-ui. jQuery-ui的事件。

Here is an example from the jQuery UI homepage: 这是jQuery UI主页上的示例:

$( "#accordion" ).accordion({    
        beforeActivate: function( event, ui ) {
                          if ( ui.newHeader.text() === "Don&#39;tActivateMe" ){
                                 event.preventDefault();        
                           }    
                        }
 });

This event can be canceled. 此事件可以取消。 So give each of the Panels a class or something to define their order, than check if the ui.newPanel class is greater than the old one. 因此,为每个面板提供一个类或一些东西来定义其顺序,然后检查ui.newPanel类是否大于旧的类。 If so, cancel the event. 如果是这样,请取消该事件。

Be aware that tihs work only from JQuery UI Versions > 1.9. 请注意,仅在JQuery UI版本> 1.9中才能使用。

Hope this helps 希望这可以帮助

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

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