javascript - ui.draggable to show if confirmation is canceled. -


i made quick list, each item can moved trash can. set once track onto trash, hides. if hit ok "confirm", removed remove().

the problem is, if click cancel confirmation, stays hidden (but want show again, because goes old location, hidden instead). tried using ui.draggable.show(), in many locations, no luck. advice?

here jsfiddle: http://jsfiddle.net/gdze8/6/

javascript/jquery:

$( init )  function init() { $(".contentitem").draggable({     revert: function (event, ui) {         if ($(event[0]).closest('.list4').length ) {         var state = !confirm("are sure want delete?")         if (!state) {           $(this).remove();          bottominfo();      } else {         return state;     }     } else {         return true;     }     } }); $(".list4").droppable( {     accept: ".contentitem",      drop: function(event, ui) {     ui.draggable.hide();       return true;     } }); } 

one way can accomplish set draggable revert, , allowing droppable function handle whether should removed or not. here js fiddle works understand question:

jquery(function () {     jquery('.contentitem').draggable({         revert: true     });     jquery('.list4').droppable({         accept: '.contentitem',         drop: function (event, ui) {             ui.draggable.hide();             if (confirm('are sure want delete?')) {                 ui.draggable.remove();             } else {                 ui.draggable.show();             }         }     }); }); 

here updated fiddle: http://jsfiddle.net/gdze8/11/

edit: not sure bottominfo() is, can absolutely call directly below ui.draggable.remove(); if desired.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -