javascript - promises : firing all chain of functions at once rather than in series -
just trying grips chaining asynchronous functions im learning use parse.com
i have function thats like:
delete_post(post_id) .then(function (){ _this.show_posts(thread_id); }).then(function (){ _this.clear_submit_forum(); })
and works ok! when add preceding function looks :
show_confirmation_alert("are absolutely sure want delete post?") .then(function(){ delete_post(post_id); }).then(function (){ _this.show_posts(thread_id); }).then(function (){ _this.clear_submit_forum(); })
my show confirmation function sort of thing:
$popup = create_popup(message) var def = new $.deferred(); $popup.find(".ok").bind("click", function (){ def.resolve(); }); $popup.find(".cancel").bind("click", function(){ def.reject(); }); $popup.popup(); $popup.popup("open"); return def.promise();
but when click ok on popup functions start running , therefore no use. want have popup call chain of functions without adding handler every time make life easier. possibly cause this. there i'm missunderstanding promises? thought function in cannot run until recieves resolved promised preceding function why on earth not chaining in series? thanks
Comments
Post a Comment