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

Rahul Akolkar rahul.akolkar at gmail.com
Wed Mar 9 22:52:22 EST 2011


Clarification on IRC during today's meeting was that comment was in
the context of programmatic usage (which makes sense ofcourse).

-Rahul


On Wed, Mar 9, 2011 at 6:26 PM, Rahul Akolkar <rahul.akolkar at gmail.com> wrote:
> Hi Bill,
>
> Inline.
>
> On Wed, Mar 9, 2011 at 4:04 PM, Bill Keese <bill at dojotoolkit.org> wrote:
>> We can wait until the next patch, but I won't be interested in any solution
>> that requires an app (or a super widget) to create global variables.
> <snip/>
>
> Let me see if I understand. I'll paste an example from Dojo docs
> (storeData is a plain JavaScript object defined in a script tag in
> this example):
>
> <div dojoType="dojo.data.ItemFileReadStore" data="storeData"
> jsId="countryStore"></div>
> <div dojoType="dijit.form.ComboBox" store="countryStore"
> searchAttr="name"></div>
>
> I assume you're OK with the above, since its a blessed example in the docs.
>
> Now let me paste a data binding example:
>
> <div dojoType="dijit.StatefulModel" data="someData" jsId="model"></div>
> <input dojoType="dijit.form.TextBox" ref="model.hello"></input>
>
> Are you saying the second one is bad (for some definition of bad)
> whereas the first one isn't? If so, please elaborate a bit more.
>
>
>>   Or anything using eval.
> <snap/>
>
> This is OK :-)
>
> -Rahul
>
>
>> On Thu, Mar 10, 2011 at 2:31 AM, Rahul Akolkar <rahul.akolkar at gmail.com>
>> wrote:
>>>
>>> Hi Bill,
>>>
>>> Inline.
>>>
>>> On Wed, Mar 9, 2011 at 4:50 AM, Bill Keese <bill at dojotoolkit.org> wrote:
>>> >
>>> >
>>> >> > 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.
>>> >
>>> > Actually, "always specified as a string" is the opposite of what I said.
>>> <snip/>
>>>
>>> Thats why I put a period after the word treated (to separate agreement
>>> from the next sentence).
>>>
>>>
>>> > Here's your current code example:
>>> >
>>> >        <div class="row" data-dojo-type="dijit.mvc.Group"
>>> > data-dojo-props="ref: 'model'">
>>> >
>>> >             <div class="row">
>>> >
>>> >                 <label class="cell" for="serialInput">Order #:</label>
>>> >
>>> >                 <input class="cell" id="serialInput"
>>> > data-dojo-type="dijit.form.TextBox"
>>> >
>>> >                                     data-dojo-props="ref:
>>> > 'Serial'"></input>
>>> >
>>> >             </div>
>>> >
>>> >             <div class="row">
>>> >
>>> >                 <label class="cell" for="lastnameInput">Last:</label>
>>> >
>>> >                 <input class="cell" id="lastnameInput"
>>> > data-dojo-type="dijit.form.TextBox"
>>> >
>>> >                                     data-dojo-props="ref:
>>> > 'Last'"></input>
>>> >
>>> >             </div>
>>> >
>>> >             <div class="row">
>>> >
>>> >                 <label class="cell" for="emailInput">Email:</label>
>>> >
>>> >                 <input class="cell" id="emailInput"
>>> > data-dojo-type="dijit.form.TextBox"
>>> >
>>> >                                     data-dojo-props="ref:
>>> > 'Email'"></input>
>>> >
>>> >             </div>
>>> >
>>> >         </div>
>>> > It's depending on a global variable named model, right?   It's bad to
>>> > depend
>>> > on global variables; it's the opposite of the direction we are trying to
>>> > go
>>> > with the  AMD work.
>>> <snap/>
>>>
>>> The variable model is in the application space, i.e. it will commonly
>>> be an application concern to set up the data model (how else would you
>>> define an application-specific model). I don't see how this is at odds
>>> with anything, let alone AMD work.
>>>
>>> Lets not create one sweeping bucket for all global variables: some are
>>> bad, others are great :-)
>>>
>>>
>>> > What I expected was:
>>> >
>>> >
>>> >   <div class="row" data-dojo-type="dijit.mvc.Group"
>>> > data-dojo-props="ref:
>>> > model">
>>> >
>>> > Eventually the parser will have a context/scope argument against which
>>> > it
>>> > will resolve variables like "model", allowing model to be a local
>>> > variable.
>>> >
>>> <snip/>
>>>
>>> There are many places where if there isn't a context supplied,
>>> dojo.global is used. This isn't any different. The actual mechanics
>>> may have something to do with the parser setting up context, or may
>>> not.
>>>
>>> As I said in my last note in $thread, let me take any magic out of the
>>> ref specification in next patch (right now, its a function of the DOM)
>>> but it will be a string, semantics to be interpreted by the data
>>> binding mixin. Then lets look at some concrete examples again.
>>>
>>> Cheers,
>>> -Rahul
>>
>>
>


More information about the dojo-contributors mailing list