Last active
December 22, 2015 11:08
-
-
Save Haraldson/6463393 to your computer and use it in GitHub Desktop.
This file contains hidden or 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( | |
['marionette', 'model/publication', 'collection/issues', 'view/detail/publication', 'hbs!template/region/main-content'], | |
function(Marionette, PublicationModel, IssueCollection, PublicationCompositeView, MainContentRegionTemplate) | |
{ | |
var MainContentRegionView = Marionette.ItemView.extend( | |
{ | |
el: '#content', | |
// Use this template initially, with a spinner or something | |
template: MainContentRegionTemplate, | |
initialize: function() | |
{ | |
this.getPublicationData('dagens', this.renderPublicationDetail); | |
}, | |
getPublicationData: function(id, callback) | |
{ | |
// get data, then | |
callback.call(this, cachedPublicationData); | |
}, | |
renderPublicationDetail: function(data) | |
{ | |
var publicationModel = new PublicationModel( | |
{ | |
title: 'Dagens' | |
}); | |
var publicationCompositeView = new PublicationCompositeView( | |
{ | |
model: publicationModel, | |
collection: new IssueCollection(data.items) | |
}); | |
console.log(publicationCompositeView.render().el); | |
// --> Perfectly fine HTML (as object), rendered with my specified templates etc. | |
// App.content is the region, which div#content is bound to -- the same region this itself is an initial view for | |
App.content.attachView(publicationCompositeView); | |
App.content.show(publicationCompositeView); | |
} | |
}); | |
return MainContentRegionView; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment