...

View Full Version : saving sort order



teedoff
06-20-2012, 01:27 AM
Ok, I have some sorting/drag and drop code that works fine as far as that basic functionality goes. I need to be able to serialize and save the sorting order to send back to the set method for the database.

Here is my js:


$(function() {
$("ul.droptrue").sortable({
connectWith: 'ul',
opacity: 0.6,
update : updatePostOrder
});

$("##sortable1, ##sortable2").disableSelection();
$("##sortable1, ##sortable2").css('minHeight',$("##sortable1").height()+"px");
updatePostOrder();
});

function updatePostOrder() {
var arr = [];
$("##sortable2 li").each(function(){
arr.push($(this).attr('id'));
});
$('##postOrder').val(arr.join(','));
}

and the ul:


<div class="left">
<div id="songList">
<fieldset class="three">
<h3>All Songs</h3>
<div id="instructions">Drag and drop or re-order Tracks</div>
<div id="songList">
<ul id="sortable1" class='droptrue'>
<cfloop from="1" to="#variables.songData.songListCnt#" index="i">
<li class="ui-state-default" id="article_1">#variables.songData.songList[i]#</li>
</cfloop>
</ul>
</div>
</fieldset>
</div>
</div>
<div class="right">
<div id="trackList">
<fieldset class="three">
<h3>Tracks on - [Album Name]</h3>
<div id="instructions">Drag and drop songs to upload and re-order Album Tracks</div>
<ul id="sortable2" class='droptrue'>
<cfloop from="1" to="#variables.songData.trackListCnt#" index="i">
<li>#variables.songData.trackList[i]#</li>
</cfloop>
</ul>
</fieldset>
</div>
</div>

Not sure how to serialize this list for the set method. Any help is greatly appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum