[dojo-contributors] dojox.mvc declarative syntax

Ed Chatelain ed.chatelain at gmail.com
Wed Mar 28 12:17:48 EDT 2012

    To give a little background for this email, we are looking to add
support to dojox.mvc to allow binding to DOM node attributes in addition
binding to widgets. We are thinking about adding support for a *
data-dojo-bind* to be able to add the support to bind to DOM nodes.  You
can read more about DOM node support here: MVC (dojox.mvc) 1.8

When Bill was reviewing the dojox.mvc spec for the DOM node support and the
1.8 updates he raised a concern about the declarative syntax in general,
because it was relying on a global *dojox.mvc.at* function which was being
created by the dojox.mvc.at code.

The current declarative syntax looks like this:
<div id=”theDivForMyWidget” data-dojo-type=”my.widget”
    data-dojo-props=”attrib0: *dojox.mvc.at*(theDataModelToBindTo,
                attrib1: *dojox.mvc.at*(‘widget:theWidgetToBindTo’,
                attrib2: *dojox.mvc.at(*‘rel:modelUnderParentModel’,
                attrib3: *dojox.mvc.at*('rel:',
The above will bind attrib0 of my.widget to the propertyInTheDataModel of
theDataModelToBindTo, etc.

The discussion of Bill's concern took place here: "MVC (dojox.mvc) 1.8

As a result of that discussion we are considering these options:
1) Remove the global setting of dojox.mvc.at, but require the application
to set a global *at* function. In this case we could use data-dojo-props or
data-dojo-bind. like this:
        <script type="text/javascript">

            ], function(parser, Stateful, mvcat){
                *at = mvcat;
*                model = new Stateful({First: "John", Last: "Doe", Email: "
jdoe at example.com"});

<div id=”theDivForMyWidget” data-dojo-type=”my.widget”
    data-dojo-props=”attrib0: *at*(theDataModelToBindTo,
                attrib1: *at*(‘widget:theWidgetToBindTo’,
                attrib2: *at*(‘rel:modelUnderParentModel’,
                attrib3: *at*('rel:',

2) Add support to have data-dojo-bind take a json array syntax which will
be used to do the binding.
This option can be seen in github here:
And the syntax will end up looking like this:
<div id=”theDivForMyWidget” data-dojo-type=”my.widget”
data-dojo-bind=”attrib0: [theDataModelToBindTo, ‘propertyInTheDataModel’],
                attrib1: [‘widget:theWidgetToBindTo’,
                attrib2: [‘rel:modelUnderParentModel’,
                attrib3: ['rel:', ‘TotalHousing', {direction: “from”,
converter: nonZeroRelConverter}]">

3) We could support both option 1 and 2, the amount of extra code is
minimal, and that would allow developers who want to avoid globals in their
applications a way to avoid them, while allowing others who like the at(..)
syntax to use it for binding.

Any input on your preferred options would be appreciated.

Ed Chatelain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20120328/b02d4910/attachment.htm 

More information about the dojo-contributors mailing list