Opened 6 years ago

Closed 4 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)

[Patch][CLA]LoadModelsPerMID.diff (3.7 KB) - added by Paul Christopher 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by Paul Christopher

comment:1 Changed 6 years ago by Ed Chatelain

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.

comment:2 Changed 4 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: newclosed

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.