Created
September 24, 2014 13:59
-
-
Save pjvds/e7c2ccc0f28745a8f06f to your computer and use it in GitHub Desktop.
Profile controller creates a like-button child components and passes values via params so that the like-button can build a model out of it. This works perfectly on the server, the model is available when rendering the view of the like-button. But it never gets dehydrated on the client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["lazoCtl"], function(Ctl) { | |
"use strict"; | |
return Ctl.extend({ | |
index: function(options) { | |
var self = this; | |
this.loadModel("profile", { | |
params: self.ctx.params, | |
success: function(model) { | |
self.profileLoaded(model, options); | |
}, | |
error: function(err) { | |
options.error(err); | |
} | |
}); | |
}, | |
// called when the profile model is loaded successfully | |
profileLoaded: function(model, options) { | |
var self = this; | |
self.ctx.models.profile = model; | |
// add like-button for portrait photo. | |
this.addChild("like-button-cmp", "like-button", { | |
params: { | |
ownerId: model.id, | |
mediaId: model.portrait.id, | |
isLiked: model.portraitLiked | |
}, | |
success: function() { | |
options.success("index"); // load the index view | |
}, | |
error: function(err) { | |
options.error(err); | |
} | |
}); | |
// todo: add like-buttons for all photo in the model.album. | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment