Skip to content

Instantly share code, notes, and snippets.

@felipeelias
Created August 14, 2011 17:42
Show Gist options
  • Save felipeelias/1145110 to your computer and use it in GitHub Desktop.
Save felipeelias/1145110 to your computer and use it in GitHub Desktop.
sync
function Dog() {
this.url = '/dogs';
this.fetch = function(callback) {
var self = this;
$.getJSON(this.url, function(attributes) {
self.attributes = attributes;
callback(attributes);
});
}
}
function View() {
this.update = function(attributes) {
console.log(attributes.id, attributes.whatever);
}
}
var dog = new Dog();
dog.fetch(function(attributes) {
var view = new View();
view.update(attributes);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment