0

Hello I am working on a JQuery nested sortable lists, I came across a plugin for nested sorting here I can drag and drop the list items successfully but I want to have an ajax call once an item in the list is dragged, Is it possible to this with this plugin ? Does it provide any option to call ajax after the drag is complete?

My JS file is

$('#sortable').nestedSortable(
   {
        disableNesting: 'no-nest',
        forcePlaceholderSize: true,
        handle: 'div',
        items: 'li',
        opacity: .6,
        placeholder: 'placeholder',
        revert: 250,
        tabSize: 25,
        tolerance: 'pointer',
        toleranceElement: '> div',
        connectWith: '.sortable',
            onChange: function(serialized) {
            },
            onStop : function(){
                var element_id = $(this).attr("id");
                var parent_id = $(this).parent().attr("id");
                var prev_sibling_id = $(this).prev().attr("id");
                if(parent_id=='trash'){
                    var url = $(this).attr("patent-trash");
                    var data = {PID:element_id};
                    $.ajax({
                        type: "POST",
                        data: data,
                        url:url,
                        cache: false,
                        success: function(data) {
                            document.location.reload(true);
                        }
                    });
                }
 });

I used onStop before which worked but there were some issues, I think the plugin is same but some updates are done 1 month ago, Is it now giving any option for calling ajax after the drag is complete or is there any alternative way to do it?

Please help me I tried all my efforts

Thanks in advance

1 Answer 1

3

I found the solution :) Since it is connect with jQuery Sortable so all the events, options and methods are available here. I used

  stop:function(){
  var element_id = $(this).attr("id");
            var parent_id = $(this).parent().attr("id");
            var prev_sibling_id = $(this).prev().attr("id");
            if(parent_id=='trash'){
                var url = $(this).attr("patent-trash");
                var data = {PID:element_id};
                $.ajax({
                    type: "POST",
                    data: data,
                    url:url,
                    cache: false,
                    success: function(data) {
                        document.location.reload(true);
                    }
                });
            }

  }

and it worked :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.