Currently, I am working with Marionette to develop an application with multiple pages. The process of instantiating views and displaying them through the appRegion in each controller/router method feels repetitive.
My goal is to streamline this process by creating methods within a loop.
var Controller = Marionette.Controller.extend({});
for(i=0;i<10;i++) {
// Implement dynamic controller methods here
}
As I delve deeper into object prototypes, I believe I can achieve this by:
var pages = [{'pageButtons': Buttons},{'pageLogin': Login}];
for(var page in pages) {
for(var method in pages[page]) {
console.log(method) // Implement dynamic method here
}
}
My question revolves around the code snippet above - how can I successfully complete it? Is there a more efficient way to handle the repetitive task of adding the same code repeatedly?