Has anyone used Javascript MVC Framework(s) to develop a production web app? If so what has been your experience? Thanks
I haven't used any specific frameworks, but I have developed an MVC-based production web app, and it's not that hard to do it yourself with the help of some other libraries.
Firstly, for Views, a good starting point is to use javascript templates (like JavaScriptTemplates) to keep all HTML markup out of your javascript files and in seperate html files. This already helps a lot.
As for Controllers and Models, I simulate similar behavior with the help of JavaScript object oriented syntax, like this:
// Create namespace for this component
App.namespace = {};
// Populate namespace
App.namespace.some_name = function () {
// Put private variables and functions here, e.g.:
// var privateVarName = 'privateVarValue';
return {
// Put public variables and functions here, e.g.:
// publicVarName: 'publicVarValue',
};
}();
In this way you can keep components separate in a way that makes sense for your app. For example, I had a App.ui.views object, where interaction with javascript templates takes place. There was also a datastore object, which contained all the Objects that represent something out of the database or other information. My personal preference was to have more fine-grained separation of specific types of controllers (seperated into several files), because they can become quite a lot in a full-scale javascript application.