I have a div element containing a ul element that starts from empty the first time the page loads. The user can then drag the li elements into this div field, which will populate the ul element. I need to hold on to li elements that were added to the ul container so that I can show li elements after the message back. How can I achieve this?
<div class="sidebar-drop-box"> <p class="dropTitle"><strong>Drop Box</strong><br /> Drag and drop tracks here temporarily if you're working with a long playlist.</p> <ul class="admin-song-list"></ul> </div>
drag and drop is done using javascript and jquery. All this is on the asp.net page. when the drag and drop is completed, this is the code that executes
function AddToDropBox(obj) { $(obj).children(".handle").animate({ width: "20px" }).children("strong").fadeOut(); $(obj).children("span:not(.track,.play,.handle,:has(.btn-edit))").fadeOut('fast'); $(obj).children(".play").css("margin-right", "8px"); $(obj).css({ "opacity": "0.0", "width": "284px" }).animate({ opacity: "1.0" }); if ($(".sidebar-drop-box ul").children(".admin-song").length > 0) { $(".dropTitle").fadeOut("fast"); $(".sidebar-drop-box ul.admin-song-list").css("min-height", "0"); } if (typeof SetLinks == 'function') { SetLinks(); }
So, I tried this code below to go through and get all the elements that are supposed to be in the drop-down list and return them back. but this did not add them to the discard window, as a result of which the changes were made to the main list
//repopulate drop box if(document.getElementById("ctl00_cphBody_hfRemoveMedia").value!="") { var localRemoveMedias=document.getElementById("ctl00_cphBody_hfRemoveMedia").value.split(","); $(".admin-left li.admin-song").each(function(){ // alert("inEach");//WORKS for(x in localRemoveMedias) { if($(this).attr("mediaid")==localRemoveMedias[x]) { AddToDropBox($(this)); } }//end for });//function(){ }
Champchris
source share