i have div element contains ul element starts off empty when page first loaded. user can drag li elements div box populate ul element. need able retain li elements have been added ul container can show li elements after post back. how can achieve this?
<div class="sidebar-drop-box"> <p class="droptitle"><strong>drop box</strong><br /> drag , drop tracks here temporarily if you’re working long playlist.</p> <ul class="admin-song-list"></ul> </div>
the drag , drop done javascript , jquery. of sits on asp.net page. when drag completed code executed
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 tried code below go through , elements suppose in drop down box , put them back. didnt add them drop box made changes master 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 });//function(){ }
to retain dragged elements across postback suggest store elements ids in asp:hiddenfield user drag/drop operations.
when postback occur ids persisted , able recreate page state before postback.
Comments
Post a Comment