Can I bind forms to a Dojo data store?
All the documentation for Dojo data store seems to point to the use of data stores for arrays or tables of data (for use in grid, for example).
Do Dojo data stores cater for form data? Can you bind a form, or in fact individual input fields to a Dojo data store? Is there any documentation with examples for this?
To clarify my question: I would like to benefit from the two-way updates and validations that you can implement with the dojo data stores, not just gather all the values from a form.
Alternatively, perhaps I am asking the wrong question. Perhaps a data store is not what I am looking for. Does Dojo provide any other concept for model开发者_如何学运维 binding?
It looks like what I am looking for is described in the links below, but this is not available yet. (According to this TRAC ticket: http://bugs.dojotoolkit.org/ticket/12314, only in version 1.7).
This will form part of the dojox.mvc package of Dojo (see http://svn.dojotoolkit.org/src/dojox/trunk/mvc/README), so while it can probably be used, it is still under development and for that matter experimental.
http://doughays.dojotoolkit.org/patterns/data_bound_widgets.html
http://chrism.dojotoolkit.org/dojomvc/
No, because a store doesn't make sense for storing that kind of information.
What you would do is store hundreds of forms in a data store. But you wouldn't store one.
If you need to get a dojo.form.Form values, you can just call getValues() on the form, and then send that to the server for persisting.
dijit.byId("form").getValues();
Good Questions, the two way model binding like KnockoutJS would be nice if it works in the dojo Framework with Internationalization features and also Validation features.
In KnockoutJS two way binding work this way:
Javascript:
function AppViewModel() {
this.firstName = ko.observable("Bert");
this.lastName = ko.observable("Bertington");
}
// Activates knockout.js ko.applyBindings(new AppViewModel());
HTML:
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
Seems like Knockout uses the Observer Pattern for two way model binding. Its good but for practical usage its not working. As i said the internationalization features are required. Users likes to input data in their own Culture. I dont use KnockoutJS.
精彩评论