我有一个手风琴,我允许对它们排序。但是对于某些部分,我不允许排序而对于某些部分,我想允许排序。是否有任何内置选项来实现这一目标?我将感激任何帮助。下面是我的代码
$( "#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( "focusout" );
//possibly change animation here; { } is default value
$(this).accordion( "option", "animate", { } );
//open previously active panel
console.log($(this).accordion);
$(this).accordion( "option", "active", "none" );
/*loadEditors();*/
//change bool to false
sorting=false;
},
update: function(event, ui) {
return;
var params = $(this).sortable('toArray');
var pageUrl = $("#orderUrl").val();
dataString = 'ordering='+params; $.ajax({
type: "POST",
url: pageUrl,
data: dataString,
success: function(data) {
}
});
}
});
这是一个小提琴的工作原理-小提琴。
只要在这些要排序的项上添加一个类,并添加"items:"。
JS
$('#accordion').accordion({
collapsible: true,
active: false
});
$("#accordion").sortable({
items: ".sortme"
});