Dynamically nested droppable of jquery droppable using AJAX and PHP -
i want create template creation web app , ui using jquery drag , drop functionality.
into ui there 3 different type of list item can drag , drop.
1) template (1st level, main container) can 1 item @ level.
2) container (2nd level, div can many , organised liner layout way).
3) blocks (3rd level, image tag, input-text).
i using ajax call php fetch template file content , response of html string.
problem if add multiple 2nd level container on 3rd level difficult understand drop item.
here code
//container drag , drop $('.container_list_item').draggable({ cursor: 'move', helper: "clone" }); /*template drag , drop */ $('.template_list_item').draggable({ cursor: 'move', helper: "clone" }); /* block drag , drop */ $('.block_list_item').draggable({ cursor: 'move', helper: "clone" }); $("#newsletterzone").droppable({ drop: function(event, ui) { var templateitemid = $(event.originalevent.toelement).attr("templateitemid"); var containeritemid = $(event.originalevent.toelement).attr("containeritemid"); if (typeof templateitemid !== typeof undefined && templateitemid !== false) { var itemidarray = templateitemid.split('_'); //call template ajex if itemidarray[0] 'template'. if(itemidarray[0] == "template") { $('.template_list_item').each(function() { if ($(this).attr("templateitemid") === templateitemid) { $(this).appendto("#selected_container_template"); } }); $.ajax({ type: "post", url: 'ajx_functionswypnewsletter.php', data: { func: 'initializetemplateview', itemid: templateitemid, }, success: function(res) { $("#newsletterzone").html(res); }, }); } }else if (typeof containeritemid !== typeof undefined && containeritemid !== false) { var itemidarray = containeritemid.split('_'); //call template ajex if itemidarray[0] 'template'. if(itemidarray[0] == "container") { $('.container_list_item').each(function() { if ($(this).attr("containeritemid") === containeritemid) { $(this).appendto("#selected_container_template"); } }); $.ajax({ type: "post", url: 'ajx_functionswypnewsletter.php', data: { func: 'initializecontainerview', itemid: containeritemid, }, success: function(res) { var htmlstring = $("#containerdivid").html(); $("#containerdivid").html(htmlstring + res); }, }); } } } }); * answer:- solved issue *
$("#newsletterzone").droppable({ hoverclass:'bg-change', drop: function(event, ui) { if(!$(this).is('.newsletterzone')){ return false; } and ajax complete remove newsletterzone class , initialise new dropping zone
complete: function () { $("#newsletterzone").removeclass('newsletterzone'); initializecontainerdroppable(); } this second level dynamic dropping zone addition.
$(".extraspaceclass").droppable({ hoverclass: "bg-change", drop: function(event, ui) {... into complete event of ajax call call function initialise 3rd level of drop zone.
Comments
Post a Comment