jquery可折叠手风琴应保持关闭状态

时间:2014-06-26 09:39:03

标签: jquery

我有一台可折叠的手风琴。当我放下手风琴时,它默认打开掉落的部分。我不想打开掉落的部分,而是当我放下任何部分时它应该保持关闭状态。这是我的代码

$( "#accordion" ).accordion({
    header: "> div > h3",
    heightStyle: "content",
    collapsible: true,
    active: false,
    activate: function( event, ui){  
        //this fixes any problems with sorting if panel was open (remove to see what I am talking about)
        if(sorting)
            $(this).sortable("refresh");   
    }
})
.sortable({
    handle: "h3",
    value: "ui-state-highlight",
    start: function( event, ui ){
        //change bool to true
        sorting=true;

        //find what tab is open, false if none
        active = $(this).accordion( "option", "active" ); 

        //possibly change animation here
        $(this).accordion( "option", "animate", { easing: 'swing', duration: 0 } );

        //close tab
        $(this).accordion({ active:false });


        unloadEditors();
    },
    stop: function( event, ui ) {            
$(this).accordion( active, false);
         loadEditors();
        sorting=false;

    },
     update: function(event, ui) {
        var params = $(this).sortable('toArray');
        //alert(params);
        var pageUrl = $("#orderUrl").val();
        dataString = 'ordering='+params;    
        $.ajax({
            type: "POST",
            url: pageUrl,
            data: dataString,
            success: function(data) {
            //data = jQuery.trim(data);             
        }
        });
    }
});

提前致谢,

阿伊莎

1 个答案:

答案 0 :(得分:0)

我已通过触发停止处理程序中的click事件修复了此问题。这是我的代码

$( "#accordion" ).accordion({
    header: "> div > h3",
    heightStyle: "content",
    collapsible: true,
    active: false,
    activate: function( event, ui){  
        //this fixes any problems with sorting if panel was open (remove to see what I am talking about)
        if(sorting)
            $(this).sortable("refresh");   
    }
})
.sortable({
    handle: "h3",
    value: "ui-state-highlight",
    start: function( event, ui ){
        //change bool to true
        sorting=true;

        //find what tab is open, false if none
        active = $(this).accordion( "option", "active" ); 

        //possibly change animation here
        $(this).accordion( "option", "animate", { easing: 'swing', duration: 0 } );

        //close tab
        $(this).accordion({ active:false });


        unloadEditors();
    },
    stop: function( event, ui ) {
ui.item.children( "h3" ).triggerHandler( "click" );
        sorting=false;

    },
     update: function(event, ui) {
        var params = $(this).sortable('toArray');
        //alert(params);
        loadEditors();
        var pageUrl = $("#orderUrl").val();
        dataString = 'ordering='+params;    
        $.ajax({
            type: "POST",
            url: pageUrl,
            data: dataString,
            success: function(data) {
            //data = jQuery.trim(data);             
        }
        });
    }
});