Put nestedSortable in page_edit.js.erb

This commit is contained in:
Christophe Vilayphiou 2012-05-12 22:12:17 +08:00
parent ef49df448d
commit 803253ebcf
2 changed files with 21 additions and 24 deletions

View File

@ -32,3 +32,24 @@ $('.part_kind').live('click', function() {
$('.part_kind_partial').hide(); $('.part_kind_partial').hide();
$('#part_' + $(this).attr('value')).show(); $('#part_' + $(this).attr('value')).show();
}); });
$(document).ready(function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'i',
helper: 'clone',
items: 'li',
maxLevels: 3,
opacity: .5,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
stop: function(event, ui) {
$.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
}
});
});

View File

@ -1,25 +1 @@
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %> <%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
<script>
$(document).ready(function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'i',
helper: 'clone',
items: 'li',
maxLevels: 3,
opacity: .5,
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() } );
}
});
});
</script>