Reputation: 52
I am attempting to extend backbone views to add a basic implementation of a layout "skeleton". This will be used to piece together a page using the different components. The problem as listed below is the scope changes for all the nested object layout pieces. Could I create closures for all of these that point to the same scope or am I limited to a single object tier? Maybe I am thinking about it wrong?
define(['backbone', 'underscore'
], function (backbone, _) {
var base = backbone.View.extend({});
_.extend(base.prototype, {
sections: {
head: {},
body: {
nav: {},
main: {
header: {
title: "",
description: "",
inner_html: function () {
return this.render().el
},
menu_items: [],
changed: false,
scripts: function () { }
},
content: {
title: "",
description: "",
inner_html: function () {
return this.render().el
},
scripts: function () { }
},
buttons: {
items: [], // { id: "save", value: "Save" }, { id: "edit", value: "Edit" }
changed: false,
scripts: function () { }
}
},
footer: {}
}
}
});
return base;
});
Upvotes: 2
Views: 302
Reputation: 3332
This looks a lot like Marionette's Layout views and regions. You may not need to write this yourself. I often use the Layout,Regions, and specialized views from Marionette without the App and Module portions.
Upvotes: 2