You can save the original index of elements (for example, via data() ), and after sorting, compare the saved index and the current index (when they do not match, the position has changed). After that, update the saved index.
$( "#accordion" ) .accordion({ header: "> div > h3", collapsible: true }) .sortable({ axis: "y", handle: "h3", stop: function( event, ui ) { var items=[]; ui.item.siblings().andSelf().each(function(){ //compare data('index') and the real index if($(this).data('index')!=$(this).index()){ items.push(this.id); } }); // IE doesn't register the blur when sorting // so trigger focusout handlers to remove .ui-state-focus ui.item.children( "h3" ).triggerHandler( "focusout" ); if(items.length)alert(items.join(',')); ui.item.parent().trigger('stop'); } }).on('stop',function(){ $(this).children().each(function(i){$(this).data('index',i)}); }).trigger('stop');
http://jsfiddle.net/DHCaA/2/
source share