Reputation: 245
I have a two radio buttons. I have onclick events on them. Whenever there is an onclick, I do some processing. This processing takes some time.
Since there is an onclick event on both the radio buttons, until the processing is done, the radio button don't change visually.
Ex: If I want to change from radio button A to B, it will only change if the processing is done.
How can I do the post processing such that, visually the radio buttons are changed and the javascript function which does the post processing runs in the background.
Upvotes: 1
Views: 62
Reputation: 73938
If your process is asynchronous, consider using dojo/Deferred
.
dojo/Deferred
will return a promise that gets resolved when the asynchronous thread is complete.
Solution using setTimeOut
will force you to specify a duration for your process, as you process could resolve sooner or later, hardcoding a value in setTimeOut
it is not a good option has you risk to make wait your user a longer time that necessary or you risk to run your code before the actual process hs been completed.
More information here:
http://dojotoolkit.org/reference-guide/1.10/dojo/Deferred.html#dojo-deferred
Upvotes: 1
Reputation: 318
Use dojo's Publish/Subscribe model, You can visually change the radio buttons and in the very next line publish to a channel from onClick handler that do post processing. Dojo's Pub/Sub documentation.
Upvotes: 0
Reputation: 1138
You can use dojo/aspect and just use aspect.after the click event to do any of your processing
Upvotes: 0