28 lines
831 B
Plaintext
28 lines
831 B
Plaintext
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
|
|
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
$('ol.sortable').nestedSortable({
|
|
disableNesting: 'no-nest',
|
|
forcePlaceholderSize: true,
|
|
handle: 'div',
|
|
helper: 'clone',
|
|
items: 'li',
|
|
maxLevels: 3,
|
|
opacity: .6,
|
|
placeholder: 'placeholder',
|
|
revert: 250,
|
|
tabSize: 25,
|
|
tolerance: 'pointer',
|
|
toleranceElement: '> div',
|
|
|
|
stop: function(event, ui) {
|
|
$.post("<%= admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
|
|
// console.log("parent: " + ui.item.parent().closest('li').attr('id'));
|
|
// console.log("id: " + ui.item.attr('id'));
|
|
// console.log("position: " + ui.item.index());
|
|
}
|
|
});
|
|
});
|
|
</script> |