Put nestedSortable in page_edit.js.erb
This commit is contained in:
		
							parent
							
								
									ef49df448d
								
							
						
					
					
						commit
						803253ebcf
					
				|  | @ -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() } ); | ||||||
|  |   	} | ||||||
|  | 	}); | ||||||
|  | }); | ||||||
|  | @ -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> |  | ||||||
		Loading…
	
		Reference in New Issue