Sha256: b4c3eb9e3b04b976afc05dd6fd9f251a7747a27b3a18c21a3bc2afe0c7a03bae

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

$(document).ready(function(){

    $('.sortable_tree').each(function() {
        $(this).nestedSortable({
            forceHelperSizeType: true,
            errorClass: 'cantdoit',
            disableNesting: 'cantdoit',
            handle: '> .item',
            helper:	'clone',
            listType: 'ol',
            items: 'li',
            opacity: 0.6,
            placeholder: 'placeholder',
            revert: 250,
            maxLevels: $(this).data('max-levels'),
            //maxLevels: #{options[:max_levels] || 5},
            //tabSize: 20,
            // protectRoot: $(this).data('protect-root'),

            // prevent drag flickers
            tolerance: 'pointer',
            toleranceElement: '> div',
            isTree: true,
            startCollapsed: false,
            //startCollapsed: $(this).data("start-collapsed"),

            relocate: function(){
                //$(this).nestedSortable("disable");
                var data = $(this).nestedSortable("serialize");
                var url = $(this).data("sortable-url");

                // update on server
                $.ajax({
                    url: url,
                    type: "post",
                    data: data
                }).always(function(){
                    //$(this).nestedSortable("enable");

                    $(this).find('.item').each(function(index){
                        if (index % 2){
                            $(this).removeClass('odd').addClass('even');
                        }else{
                            $(this).removeClass('even').addClass('odd');
                        }
                    });

                }).done(function(data){

                }).fail(function(jqXHR, textStatus){

                });


                //$(this).nestedSortable("enable");
            }
        }); // nested tree
    });


}); // document.ready

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sortable_tree_rails-0.0.10 lib/assets/javascripts/sortable_tree.js
sortable_tree_rails-0.0.9 lib/assets/javascripts/sortable_tree.js
sortable_tree_rails-0.0.8 lib/assets/javascripts/sortable_tree.js