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

Bill Keese bill at dojotoolkit.org
Sun Mar 6 23:05:37 EST 2011


It's confusing to tell users to specify the binding one way at creation
(using "ref"), and another way when changing the binding (using "binding").
   Why not be consistent?

On Mon, Mar 7, 2011 at 9:22 AM, Rahul Akolkar <rahul.akolkar at gmail.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110307/8c2634b5/attachment.htm 


More information about the dojo-contributors mailing list