jQuery Sortables
jQuery Sortables
I am creating a navigation menu where you can sort the top level links.
We need to be able to save the new order after they are arranged. I have tried using
var result = $('#placeholderSortable').sortable('toArray'); but whenever I call result it always says "undefined". I need help!
Here is my code:
-
<script type="text/javascript" src="../jquery/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../jquery/ui/ui.core.js"></script>
<script type="text/javascript" src="../jquery/ui/ui.sortable.js"></script>
<script type="text/javascript" src="../jquery/ui/effects.core.js"></script>
<script type="text/javascript">
$(document).ready( function(){
$('#placeholderSortable').sortable('toArray');
$("#placeholderSortable").sortable({
placeholder: "top",
forcePlaceholderSize: true,
revert: true
})
});
</script>
My list/navigation menu is here between these scripts.
The element's ids are pos_1, pos_2, pos_3, pos_4, etc.
-
<script type="text/javascript">
var result = $('#placeholderSortable').sortable('toArray');
function position_num(){
alert(result);
}
</script>
<button onClick="position_num();">Position</button>
You can see how it is not working on this test page, feel free to view the source:
Click position to receive the alert containing the variable result
http://dalelarsen.com/dalelarsen/beta13/
Thanks!