Skip to content

Instantly share code, notes, and snippets.

@jberthet
Last active December 27, 2015 17:39
Show Gist options
  • Select an option

  • Save jberthet/7363689 to your computer and use it in GitHub Desktop.

Select an option

Save jberthet/7363689 to your computer and use it in GitHub Desktop.
/* mainPane and view hierarchy skipped */
manifestationDetailsView: SC.View.extend({
layout: { centerX: 0, width: 200, top: 20, height: 150},
contentBinding: 'Bvc.manifestationController',
render: function (ctx) {
var manif = this.get('content');
// If I do things this way ... everything work fine and I don't need to refresh the view ... but it's not the goal in Sproutcore :)
//var manif = Bvc.manifestationController.get('content');
if (manif) {
ctx = ctx.begin('span')
.push(manif.get('nom'))
.end();
}
}
// This the only way I found to update my view since content is 'undefined' the first time render() is called
checkController: function () {
SC.Logger.log('content');
this.updateLayer();
}.observes('content')
})
// This statechart structure should render the pane only when controller's content is ready ...
Bvc.statechart = SC.Statechart.create({
initialState: 'readyState',
readyState = SC.State.extend({
initialSubstate: 'isLoadingState',
enterState: function () {
var manif = Bvc.store.find(Bvc.Manifestation, 1);
Bvc.manifestationController.set('content', manif);
this.didLoadData();
},
didLoadData: function () {
if (Bvc.manifestationController.get('status') === SC.Record.READY_CLEAN) {
this.gotoState('showingAppState');
}
}.stateObserves('Bvc.manifestationController.status'),
isLoadingState: SC.State.extend({
enterState: function () {
//TODO: Append a loading panel
SC.Logger.log('isLoadingState');
}
})
}),
showingAppState = SC.State.extend({
enterState: function() {
Bvc.getPath('mainPage.mainPane').append();
},
exitState: function() {
Bvc.getPath('mainPage.mainPane').remove();
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment