[dojo-contributors] dojox.mvc declarative syntax

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


Hi,
    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
specification<https://docs.google.com/document/d/1ejZlUwySI0q3n3scInw30drHa7no7Zm-WSZqtYx5scE/edit?disco=AAAAAEieNOY#heading=h.s4d8nc3ag8xo>

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,
‘propertyInTheDataModel’),
                attrib1: *dojox.mvc.at*(‘widget:theWidgetToBindTo’,
‘attributeInTheWidget’),
                attrib2: *dojox.mvc.at(*‘rel:modelUnderParentModel’,
‘propertyInTheChildModel’),
                attrib3: *dojox.mvc.at*('rel:',
'TotalHousing').direct(“from”).attach(nonZeroRelConverter)">
</div>
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
specification<https://docs.google.com/document/d/1ejZlUwySI0q3n3scInw30drHa7no7Zm-WSZqtYx5scE/edit?disco=AAAAAEieNOY#heading=h.la2d6iz6tzoe>"


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

require(["dojo/parser","dojo/Stateful","dojox/mvc/at","dijit/form/Button","dijit/form/TextBox","dojo/domReady!"
            ], function(parser, Stateful, mvcat){
                *at = mvcat;
*                model = new Stateful({First: "John", Last: "Doe", Email: "
jdoe at example.com"});
                parser.parse();
            });
        </script>

<div id=”theDivForMyWidget” data-dojo-type=”my.widget”
    data-dojo-props=”attrib0: *at*(theDataModelToBindTo,
‘propertyInTheDataModel’),
                attrib1: *at*(‘widget:theWidgetToBindTo’,
‘attributeInTheWidget’),
                attrib2: *at*(‘rel:modelUnderParentModel’,
‘propertyInTheChildModel’),
                attrib3: *at*('rel:',
'TotalHousing').direct(“from”).attach(nonZeroRelConverter)">
</div>


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:
https://github.com/asudoh/dojox_mvc/tree/nonfunctionsyntax
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’,
‘attributeInTheWidget’],
                attrib2: [‘rel:modelUnderParentModel’,
‘propertyInTheChildModel’],
                attrib3: ['rel:', ‘TotalHousing', {direction: “from”,
converter: nonZeroRelConverter}]">
</div>

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.

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