Skip to content

Providing Synchronous / Asynchronous Flexibility With jQuery.when

18. April 2012

Javascript works asynchronously. But sometimes you need some synchronicity. Derick Bailey has a nice post about this:

http://lostechies.com/derickbailey/2012/03/27/providing-synchronous-asynchronous-flexibility-with-jquery-when/

Example

var that = this;

var templateRetrieved = this.getTemplate();

$.when(templateRetrieved).then(function(template){
   var html = that.renderTemplate(template, data);
   that.$el.html(html);

});
Advertisements

From → jQuery

Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: