Using jQuery deferred promises -


So I'm very new to these promises. I have a difficult time wrapping my head around me. I've noticed a lot of tots and so many posts, but nothing in my situation has come here is my current code.

  $ ("# PayNow, input [name ^ = 'schedulepmt']"). ("Blur", function () {var diff = 0; diff = calcBalanceDue (); if diff {$. (When confirming new payment) then (function () {if ($ (this) .attr ("id") === "PayNow" & amp; input [Name ^ = 'schedulepmt']. Length & amp; amp; amp; amp; $ (this) .val ()! == $ (this) .data ("prevValue")) {if (! ResetPmtInfo ()) {$ (this) .val ($ (this) .data ("prevValue"));}}}})}});  confirmNewPayment ()  has been executed after I like the code inside  .then () . It seems that there are still all running async.  

Thank you.

Confirm the function here (Diff) {bootbox.dialog ({Message: "An outstanding balance. How do you want to proceed? ", Title:" outstanding balance option ", close button: false, button: {addpmt: {label:" add a scheduled copy payment ", classname:" btn-success ", callback: function () {Scheduled Pmdata PaymentCant + = 1; $ ("# Scheduled Payment"). Endand ($ ("# Scheduled PMT Template"). Render (Schedule PMTData, {Amount: "BTN-Primary", Callback: Function () {$ ("# BalancesWRO"). RemoveClass ("Hide"); $ ("# BalanceDu"). Val (diff);}}}}) ;}

Your confirmed new payment payment should return a promise: Confirm the function New payment (difference) {var deferred = $. Passive (); // your async action here (function () {// $ deferred.resolve (diff * 2) when deferred object; }) (); Refund. Promis ();}


for updates A:

The bootbox was returning the promise by the design, so if everything is easy then in this case you can

  confirm the functionNew payment (difference) { Var deferred = $ Idle (); Bootbox.dialog ({Message: "An outstanding balance. How would you like to proceed?", Title: "Outstanding Balance Option", Close Button: Wrong, Button: {addpmt: {label: "Scheduled CC Payment Deferred.resolve ('schedule');}}, collect: {label: "Mark the balance as" Primary ", callback: function {$ (" # sshnienuirve ") .removeClass (" hide "); $ (" # balances "). Val (difference); deferred .olol ('mark');}}}} ); Refund suspended. }  

...

  $ ("#pay-nova, input [name = = 'scheduledmate']"). ("Blurred", function () {.... confirmNewPayment (diff). Then (function (selection) {// selection 'schedule' or 'mark'})}}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -