I'm learning dojo to develop a simple application to be used from mobile clients. I see some widgets have different features between dojox/mobile/* and dijit/form/*. For example the ComboBox from dijit has a property to select which field of a Memory store use (searchAttrb) while the one from dojox hasn't:
https://dojotoolkit.org/reference-guide/1.10/dojox/mobile/ComboBox.html
https://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html
first question: would you recommend the use of
dijitwidgets for an application that will be used from smartphones?I know what
dojo/domReady!means. But I'm not sure if I have to use it also in nested requires. Example:require(["dojo/request/xhr", "dojo/json", "dojo/domReady!"], function (xhr, JSON) { xhr("api/dummy", { handleAs: "json" }).then(function (data) { require(["dojo/store/Memory", "dijit/form/ComboBox", "dojo/domReady!"], function (Memory, ComboBox) { var mystore = new Memory({ data: data }); var comboBox = new ComboBox({ id: "idCombo", name: "blabla", store: mystore, searchAttr: "field" }, "idCombo").startup(); }); }, function (err) { console.log(err); }); });
This snippet retreives a file on the server and create the Memory store. Then uses the field "field" to populate the ComboBox. Does the inner dojo/domReady! is required? I guess no, because that code is reached only after the outer function has been executed.
- I see a lot of
dojoexamples written in different manner. Some declare all the require items just after thedojoinclude. Others require only the items the functions need, function by function. What are the differences?
Examples
declares all the items together, and without a function associated, so no names for the items:
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script>
<script type="text/javascript">
require([
"dojox/mobile",
"dojox/mobile/parser",
"dojox/mobile/compat",
"dojox/mobile/Button",
"dojox/mobile/CheckBox",
"dojox/mobile/ComboBox",
"dojox/mobile/RadioButton",
"dojox/mobile/Slider",
"dojox/mobile/TextBox",
"dojox/mobile/SearchBox",
"dojox/mobile/ExpandingTextArea",
"dojox/mobile/ToggleButton"
]);
while here:
https://dojotoolkit.org/documentation/tutorials/1.10/checkboxes/demo/CheckBox.html
the require instruction is followed by a function:
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="isDebug: 1, async: 1, parseOnLoad: 1"></script>
<script>
require(["dijit/form/CheckBox", "dojo/parser", "dojo/domReady!"], function(CheckBox, parser) {
Of course they should have different meaning and use cases, but I'm not sure to understand which.