Skip to content

Instantly share code, notes, and snippets.

@kdonald
Created August 17, 2011 02:40
Show Gist options
  • Save kdonald/1150698 to your computer and use it in GitHub Desktop.
Save kdonald/1150698 to your computer and use it in GitHub Desktop.
$.Deferred refactoring
// BEFORE $.Deferred()
mainView.render(function(root) {
var mainContent = root.find("#content");
subView.render(function(el) {
mainContent.append(el);
nestedView.render(function(el) {
mainContent.append(el);
allDoneCallback(root);
});
});
});
// AFTER $.Deferred()
mainView.render().append(subView, "#content").append(nestedView, "#content").done(allDoneCallback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment