I am trying to feel my way around a dojox/app application and understand it. As suggested here, the contents on config.json end up in a variable called config simply enough, but the existing app I am tinkering with does a lot of its mechanics downstream of the main.js setup in another .js file where a bit of the config variable JSON is referenced. modules within config is exposed, but I want to have at views (both reading from it and writing to it) which sits not within modules but parallel to it within the config hierarchy. A pointer lingers at modules which allows me to reach out to views through a "parent."
app.reopenView = function(domNode, transOpts, evt) {
var views = app.modules.__parent.views;
var domain = transOpts.target.split(",")[0];
var view = transOpts.target.split(",")[1];
var domainSpecs = _.filter(views, function(a,b) {
return b == domain;
})[0];
var dummyDomain = nameDummyDomain();
views[dummyDomain] = domainSpecs;
app.modules.__parent.views[dummyDomain] = domainSpecs;
transOpts.target = dummyDomain + "," + view;
app.openView(domNode, transOpts, evt);
};
This doesn't make any sense to me as of yet. I'll let you know when it does. How is this state hanging out?
Note: Having just written this, I now realize that I am a moron. app.views is available just as app.modules.__parent.views is. Duh. Mystery solved.
Addendum: OK, now I have had a peer review and it has been pointed out to me that I did not need to use underscore.js whatsoever and that the line using it could just read as:
var domainSpecs = views[domain];
Duh.
No comments:
Post a Comment