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

Rahul Akolkar rahul.akolkar at gmail.com
Sun Mar 6 17:14:15 EST 2011

Hi Ben,


2011/3/5 ben hockey <neonstalwart at gmail.com>:
> in support of something Bill touches on here which hasn't been discussed
> much up until this point, i want to comment that i think the implementation
> downplays the significance of creating widgets programmatically.  there was
> a comment in one of the files (i think StatefulModel?) that left me with the
> impression that the assumption was made that widgets are created
> declaratively in the majority of cases.  typically i almost never use
> widgets declaratively and so in my small world the programmatic case is the
> most common.  based on the way the parser works, if you can get the
> programmatic case working then declarative will just fall into place.  i
> just want to echo bill's comments related to making the programmatic case
> work.

Yes, it will be made so. We happened to start with the markup-driven
cases extensively, I wouldn't want others to read that as considering
the programmatic cases any less useful or important :-)

> also another thought i had related to walking the DOM is that in a few
> cases, we move widgets from their original place in the DOM to be children
> of body.  it may turn out that there isn't a use case where this matters -
> however, an interesting one i can think of would have to do with a context
> menu that might try to get state from a "parent".  for example, certain
> options in the menu may be enabled/relevant based on the state of a model
> shared with a parent widget and the context menu may have been declared as a
> DOM descendant of that parent widget.  will it be that this context menu is
> actually not able to find it's ref because it gets moved to be a child of
> the body?

Using the DOM to figure out parent data binding contexts is often the
simplest, even from a user understanding perspective. However, as
mentioned when I talked about the lexical space (ref) and value space
(binding) separation, this (DOM) needn't be the only way to ascertain
the data binding context. In fact, I've been in discussions where we
have considered using a reference to the parent data-bound dijit (say,
via widgetId) as a legal way to specify the widget relative ref (say,

So there isn't a necessary implication that the data binding axis need
always align with the DOM ancestor axis, though its intuitive in a
large number of cases so we can use that without having the user be
very explicit about it in those cases.

We can certainly explore this in more detail any time, with your
specific menu example, or more generally.


More information about the dojo-contributors mailing list