Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- КОДЕ подрубающий магическую сортировку:-->
- <%= javascript_tag do %>
- jQuery( function($) {
- $('.sortable').smmNestedSortable({
- 'serializer':function() {
- var spec = $('.sortable').smmNestedSortable.jsonSerializer.buildSpec("first");
- $("#spec").html("<b>json output</b><br /><br />"+ spec);
- updateOrder(spec);
- }
- });
- });
- jQuery( function($) {
- $('#test').smmNestedSortable({
- 'serializer':function() {
- var spec1 = $('#test').smmNestedSortable.jsonSerializer.buildSpec("last");
- $("#spec").html("<b>json output</b><br /><br />"+ spec1);
- updateOrder(spec1);
- }
- });
- });
- function updateOrder(mass)
- {
- jQuery.post('<%= update_sort_path -%>', { 'mass' : mass })
- }
- <% end %>
- <!-- Кодэ исходнеГ плагина -->
- $.fn.smmNestedSortable.jsonSerializer = {
- 'buildSpec': function() {
- var spec = [];
- jQuery("ul.sortable:first").children().each(function() {
- spec.push($.fn.smmNestedSortable.jsonSerializer._buildSpec($(this)));
- });
- return $.toJSON(spec);
- },
- '_buildSpec': function(liList) {
- var spec = [];
- liList.each(function() {
- if(this.id != 'empty') {
- var li=this;
- var node = {
- title: li.id
- };
- node.children = $.fn.smmNestedSortable.jsonSerializer._buildSpec(jQuery(li).children("ul").children("li"));
- spec.push(node);
- }
- });
- return spec;
- }
- };
- <!-- Проблема в том, что магия сортировки работает на оба списка и на .sortable и на #test, но json output приходит только по тому списку, который первым идет на HTML страничке -->
Add Comment
Please, Sign In to add comment