我在 HTML 页面中有以下部分:
<div>
<label style="margin-right:5px;vertical-align:middle;">Index</label>
<div data-dojo-type="dojo/store/Memory" data-dojo-id="indexStore"
data-dojo-props="data: [{id: 1, name: 'ID'}]"></div>
<input id="indexcombo" name="indexselector" type="text"
data-dojo-type="dojox/mobile/ComboBox" style="width: 122px;
vertical-align: middle;" value="ID" data-dojo-props="store:indexStore,
searchAttr:'name'"></input>
</div>
在一个单独的 JavaScript 文件中,我有这个:
require([
"dojo/on",
"dojo/dom",
"dojo/dom-attr",
"dojo/request",
"dojo/json",
"dojo/_base/array",
"dojo/_base/window",
"dojo/dom-construct",
"dijit/dijit",
"dijit/registry",
"dojo/parser",
"dojo/store/Memory",
"dojox/mobile",
"dojox/mobile/deviceTheme",
"dojox/mobile/Heading",
"dojox/mobile/Accordion",
"dojox/mobile/ContentPane",
"dojox/mobile/FormLayout",
"dojox/mobile/TextBox",
"dojox/mobile/SimpleDialog",
"dojox/io/xhrScriptPlugin",
"dojox/mobile/RoundRectStoreList",
"dijit/form/DataList",
"dojox/mobile/ComboBox",
"dojox/mobile/Button",
"dojox/mobile/GridLayout",
"dojo/domReady!"
],
function(on, dom, domAttr, request, json, array, win, domconstruct, dijit, registry,
parser, memory, mobile, deviceTheme, heading, accordion, contentpanel,
formlayout, textbox, simpledialog, xhrscriptplugin, roundrectdatalist,
datalist, combobox, button, gridlayout)
{
var indexcombo = dom.byId("indexcombo");
var indexcombowidg = registry.byId("indexcombo");
...
}
我只是在扯我的头发。我总能得到 indexcombo 但 indexcombowidg 总是失败。我需要处理 ComboBox 的 onChange 事件,以便可以更改当前索引的值,但是我尝试的任何操作都无法连接到该事件。我正在 Firefox 和 Chrome 中对此进行测试。
任何建议,将不胜感激。我花费数小时在 JavaScript 中做在大多数其他语言中需要几分钟的事情,这变得越来越令人沮丧。
问候, 尼尔