how to alternatively resolve and reject jquery object -



how to alternatively resolve and reject jquery object -

is possible resolve jquery deferred object , reject it, , resolve again, etc. , trigger $.when each time resolved ?

i trying this, doesn't work :

var bindhide = $.deferred(); var bindshow = $.deferred(); if ($('#userdata').is(':hidden')) { bindshow.resolve(); } else { bindhide.resolve(); } //show userdata $.when(bindshow).then(function() { bindshow.reject(); $('#miniweightlevel, #miniweightleveltextlayer').unbind('vclick').bind('vclick', function (e) { showuserdata(); $('#miniweightlevel, #miniweightleveltextlayer').unbind('vclick'); bindhide.resolve(); }); }); //hide userdata $.when(bindhide).then(function() { bindhide.reject(); $('#minifycross').unbind('vclick').bind('vclick', function (e) { hideuserdata(); bindshow.resolve(); }); });

a given deferred can rejected or resolved once. and, since $.when() returns promise, rejected or resolved 1 time too. so, no cannot work asking to.

standard deferreds , promises not designed general purpose notification scheme how trying utilize them. jquery's implementation has notify feature utilize this, standards effort moving capability out of promises , done differently.

it sounds me more need notification scheme or custom events, not promises designed one-way. resolved or rejected 1 time , never alter again.

jquery jquery-deferred

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -