Skip to content

Instantly share code, notes, and snippets.

@ericktai
Created May 31, 2012 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericktai/2846570 to your computer and use it in GitHub Desktop.
Save ericktai/2846570 to your computer and use it in GitHub Desktop.
Chained Calls
/*
For chained functions, simply call the second, third, fourth functions in the "success" callbacks
Callbacks: http://www.stackmob.com/devcenter/docs/Javascript-SDK-API#a-success
These calls will execute in order 1 by 1, not simultaneously.
*/
var user = new StackMob.User({ username: 'chucknorris', password: 'myfists' });
user.login(false, {
success: function(model) {
//by the way, the full user object is returned in the current API in "model"
//but if you wanted to do a second call..
user.fetch({
success: function(model) {
//and a third call
user.fetch({
success: function(model) {
//and a fourth call
var todos = new Todos();
todos.fetch();
}
})
}
});
},
error: function() {
//some error
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment