You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But it's pretty easy to convert the DOM changes to JSON by adding code, check this example:
// call it from reorder/level change event for example (and you could use it on the other event listeners)sortable.onSortCompleted(async(event,ui)=>{awaitdelay();varobj=FetchChild();// get the object// Now you can send it via ajax to your server// [...]console.log(JSON.stringify(obj,null,2));// just print the output in console });functionFetchChild(){vardata=[];// #sortable is your <ul> tag, change it$('#sortable > li').each(function(){data.push(buildJSON($(this)));});returndata;}functionbuildJSON($li){varthis_id=$li.attr("data-id");varparent_id=$li.attr("data-parent");varlevel=$li.attr("data-level");if(level==1){parent_id=0;}vartitle=$li.find(".branch-title").html();varsubObj={"id": this_id,"parent_id": parent_id,"level": level,"title": title};$li.children('ul').children().each(function(){if(!subObj.children){subObj.children=[];}subObj.children.push(buildJSON($(this)));});returnsubObj;}
How can we call the result of our changes in json format?
The text was updated successfully, but these errors were encountered: