backbone.js - How to Load backbone views from modules using RequireJS? -


define(['jquery','frameworkviews/backboneprototype','applicationpath/module1/js/views/appview1','applicationpath/module2/js/views/appview2'],    function($,backboneprototype,appview1,appview2){   function getviews(modules,type){     var views= new array();     ( var = 0; < modules.length; ++i) {       var cmd = 'views[' + + '] = new ' + modules[i]+'view.'+modules[i]+type + "view" + '() ;';       eval(cmd);       views[i].name = modules[i];     }     return views;   } }); 


developing project backbone , requirejs. our project based on framework , modules architecture. modules contribute backbone views ( appview1/appview2 etc) , dynamically loaded framework using requirejs shown above.the problem facing if new module added (e.g. module3) again above framework code needs modified add module3 views define block. there way avoid such changes in framework , how obtain reference newly added module view?

don't use eval. that's evil (no pun intended).
i'll assume not real code, you're not returning here.

about problem, think you'll find need here: variable function names in require & backbone.

either solutions suit you.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -