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

Rahul Akolkar rahul.akolkar at gmail.com
Wed Mar 9 02:49:50 EST 2011


Hi Bill,

Inline.

On Mon, Mar 7, 2011 at 10:51 PM, Bill Keese <bill at dojotoolkit.org> wrote:
> Thanks.   I think it will be easier to see what's going on when you convert
> those test cases to the new parser format.   And/or write programmatic test
> cases.
<snip/>

There is an existing new parser format test in the patch (grep for
"newparser"), some others can be converted to the new format as well
if it helps. And I expect to have a refreshed patch in a couple of
days with the programmatic test cases.


> After that I want to take a look at when you are using "ref" as a
> string and when you are using it as an object.   I'm guessing it's always an
> object except when it's a value relative to a parent node, in which case
> it's a string.
>
<snap/>

Right, thats how its treated. Its always specified as a string. I have
a change or two in mind here to potentially eliminate all DOM
navigation operations in some cases, so let me try to get that into
the next version of the patch too.

BTW, I've requested you take another look at #12399 (details on the ticket).

-Rahul


> On Tue, Mar 8, 2011 at 5:32 AM, Rahul Akolkar <rahul.akolkar at gmail.com>
> wrote:
>>
>> 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