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

Rahul Akolkar rahul.akolkar at gmail.com
Mon Mar 7 15:32:51 EST 2011


Hi Bill,

Inline.

On Sun, Mar 6, 2011 at 11:05 PM, Bill Keese <bill at dojotoolkit.org> wrote:
> 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?
>
<snip/>

Its good to have had this discussion at a more abstract level, since
most code examples tend to just work (as those in your previous email)
which may be the reason why this hasn't been an issue for those who've
seen/used this work.

If it confused you, it will likely confuse others as well. With that
in mind, I've moved to only using the ref string in the docs and all
examples (both at creation and later). I've refreshed the patch on
ticket #12314 accordingly.

I may, at some point with the gift of copious free time, write a
separate MVC specification [1] document for dijit that outlines refs
and bindings in more detail from an implementor's perspective, but the
users needn't care about anything other than ref.

And by the by, I'd like to get a change into _WidgetBase's
implementation of dojo.Stateful. Please see ticket #12399 for details
(which I didn't tag under dijit at creation and now I can't, so I'll
mention it here too):

  http://bugs.dojotoolkit.org/ticket/12399

-Rahul

[1] https://docs.google.com/document/d/17Axms_4-llLCWkIzZvuHC3SvEH-38eFIKWITZaWk4aU/edit?hl=en&authkey=CKfc6A4&pli=1#


> 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
>
>


More information about the dojo-contributors mailing list