dojo - Dojox/mvc/at model scope -


when using stateful object in dojox/mvc package, declarative examples seems have target model in global namespace (defined without "var" keyword). violates general practices of javascript design polluting global namespace, not mention making use of different models difficult , messy.

my question is, what's scope of declarative at() , how 1 use model lies inside context/scope?

http://dojotoolkit.org/reference-guide/1.9/dojox/mvc.html#id6

where dojox/mvc/at api typically used in data-dojo-props. 3 things comes mind talking setting "scope" there:

  1. running dojo parser parser.parse(rootnode, {propsthis: scopeobj}); can make this in data-dojo-props specified object. in way data-dojo-props="widgetprop: at(this, 'scopeobjprop')" points property in scopeobj.
  2. in widgets-in-template, data-dojo-props="widgetprop: at(this, 'widgetsintemplateprop')" points property in widgets-in-template instance.
  3. relative data binding makes target property in widget in dom referred via "rel:" special syntax. setting object target property there, registry.byid("scopewidget").set("target", {first: "john", last: "doe"}); in below example, populate value in <input>:

    <script type="dojo/require">at: "dojox/mvc/at"</script> <div id="scopewidget"  data-dojo-type="dijit/_widgetbase"  data-dojo-props="target: {}">     <div>         first:         <input data-dojo-type="dijit/form/textbox"          data-dojo-props="value: at('rel:', 'first')">     </div>     <div>         last:         <input data-dojo-type="dijit/form/textbox"          data-dojo-props="value: at('rel:', 'last')">     </div> </div> 

hope helps.

best, akira


Comments