[dojo-contributors] MVC support for dijit based on dojo.Stateful

Rahul Akolkar rahul.akolkar at gmail.com
Sun Mar 6 19:22:26 EST 2011


Hi Bill,

Inline.

On Sun, Mar 6, 2011 at 6:08 PM, Bill Keese <bill at dojotoolkit.org> wrote:
> OK, it seems confusing that an app can specify either ref or binding, and
> they can essentially be the same thing:
>      new dijit.form.TextBox({ref: 'myStatefulModel.employeeName'})
> vs.
>      new dijit.form.TextBox({binding: myStatefulModel.employeeName})
<snip/>

In the above simple example, they are indeed the same. However, at
times you don't want to specify the binding (model node) directly. For
example, when you want it to be relative to the parent, you just want
to specify the relative bit (so it can change with parent's binding).

Simple rule for users is -- at widget instantiation / page load use
ref; for dynamic updates to binding later use binding.

All docs and examples follow this pattern, so the message is consistent.


> Typically how this is done in dojo is to separate the object and the
> attribute, ex:
>     dojo.connect(obj, "attr", ...)
> What if you did that instead?   If you separated out the parameters like
> dojo.connect() does then a simple binding would look like:
>   <input id="zipInput" data-dojo-type="dijit.form.NumberTextBox"
> data-dojo-props="binding: loanModel, ref: "zip"">
<snap/>

Though the binding above is really the parent binding (not this
textbox's). Here, the parent binding is explicitly specified,
elsewhere we may infer it from the DOM or specify the parent's
widgetId itself. Perhaps a better way to say what I am saying is that
to your examples below ...


> A binding with a parent would look like:
>
>  <div data-dojo-type="dijit.mvc.Group"
> data-dojo-props="binding: searchRecords">
>
>       <input data-dojo-type="dijit.form.TextBox"
> data-dojo-props="ref: 'Query'/>
>
> The hard part becomes nested relative bindings, but I guess it could be
> ref's all the way down, except for the top level node:
>
>   <div data-dojo-type="dijit.mvc.Group" data-dojo-props="binding: searchRecords">
>
>       <div data-dojo-type="dijit.mvc.Repeat"
> data-dojo-props="ref: 'Results'">
>
>           <input data-dojo-type="dijit.form.TextBox"
> data-dojo-props="ref: 'Query'/>
>
<snip/>

These already work :-)

-Rahul


More information about the dojo-contributors mailing list