ilikenwf / nestedSortable

A jQuery plugin that extends Sortable UI functionalities to nested lists.
645 stars 221 forks source link

Uncaught RangeError: Maximum call stack size exceeded #119

Closed craigpotter closed 6 years ago

craigpotter commented 6 years ago

Has anyone had this issue before?

It seems to happen when I move items around a lot ... then trigger an ajax call.

function saveMenu(){
    var deferredObject = $.Deferred();
    var saveBtns = $(".saveMenu"); 
    saveBtns.prop("disabled", "disabled").html('<i class="fa fa-floppy-o" aria-hidden="true"></i> Saving'); 
    var arraied = $('ol.sortable').nestedSortable('toHierarchy', {startDepthCount: 0});

    $.each(arraied, function(key,value){
        delete value['nestedSortable-item'];
    })
        $.ajax({
        type: "POST",
        url: "ajax/url",
        data: {data:arraied}, // ISSUE SEEMS TO HAPPEN HERE 
        success: function(result) {

            deferredObject.resolve();
        },
        fail: function(){
            deferredObject.reject();
        }

       });
       var saveBtns = $(".saveMenu"); 
        saveBtns.prop("disabled", false).html('<i class="fa fa-floppy-o" aria-hidden="true"></i> Save');
       return deferredObject.promise();
}

The issue seems to happen at this line data: {data:arraied} and the AJAX call never gets called.

This only seems to happen if I move items around first however.

Any ideas ?

craigpotter commented 6 years ago

I found my issue.

image

Looks like nestedSortable-item object was being attached to all items.

Manually removed these and it seems to work now.