Opened 8 years ago
Closed 5 years ago
#16946 closed enhancement (patchwelcome)
[Patch][CLA] dojox/app: Support loading of models per MID
Reported by: | Paul Christopher | Owned by: | Ed Chatelain |
---|---|---|---|
Priority: | undecided | Milestone: | 1.13 |
Component: | DojoX App | Version: | 1.9.0b1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
As already discussed on the mailing list (see http://dojo-toolkit.33424.n3.nabble.com/dojox-app-How-to-separate-model-definition-into-a-file-tp3995281.html), it would be nice if models could be loaded/instantiated by providing a MID. So you can write in the appconfig.json file:
... "views": { "home": { "dependencies": [...], "template": "./home/view.html", "controller": "./home/controller.js", "model": { "names": { "modelLoader": "dojox/app/utils/mvcModel", "type": "dojox/mvc/ModelRefController", "params":{ "mid": "./home/model.js" } } } }, ...
Whereas ./home/model.js is an AMD module that returns a class or a singleton:
define([ "dojo/_base/declare", "dojo/Stateful" ], function(declare, Stateful){ // Return a class. Could also return a singleton? return declare(Stateful, { myprop1: 5, myprops2: ... _setMyProps3Attr: function (value) { // A custom setter .... this._set('myProps3', value); }, constructor: function(){ this.myprops3 = [1, 2, 3, 4]; } }); });
Attachments (1)
Change History (3)
Changed 8 years ago by
Attachment: | [Patch][CLA]LoadModelsPerMID.diff added |
---|
comment:1 Changed 8 years ago by
comment:2 Changed 5 years ago by
Milestone: | tbd → 1.12 |
---|---|
Resolution: | → patchwelcome |
Status: | new → closed |
Given the lack of attention to this ticket, we would accept a pull request. Closing as patchwelcome.
Note: See
TracTickets for help on using
tickets.
Thanks for the patch, but it is too late to add new function to 1.9, so this will have to wait. The good news is that you can easily add your own custom model to your app to do this without having to wait for the update in dojox/app.