这可能在最近的 Dojo 中得到修复 - 请参阅http://bugs.dojotoolkit.org/ticket/15141 - 但使用 1.7.3 我发现这有效:
在我的应用程序目录中,与 dojo、dijit 和 dojox 处于同一级别,我创建了一个文件 InlineSelectBox.js,该文件扩展了 InlineEditBox,其中包含用于根据 Dijit 的值设置关联 domNode 上的 HTML 的代码,并将该代码连接到onChange() 事件:
define(["dijit/InlineEditBox",
"dijit/form/Select",
"dojo/on",
"dojo/_base/declare",
"dojo/_base/array"
],
function(InlineEditBox, Select, on, declare, array){
return declare(InlineEditBox, {
_setLabel: function() {
array.some(this.editorParams.options, function(option, i){
if (option.value == this.value) {
this.domNode.innerHTML = option.label;
return true;
}
return false;
}, this);
},
postMixInProperties: function(){
this.inherited(arguments);
this.connect(this, "onChange", "_setLabel");
},
postCreate: function(){
this.inherited(arguments);
this._setLabel();
}
});
});
然后,在我看来脚本:
require(["dojo/ready",
"app/InlineSelectBox",
"dijit/form/Select"
],
function(ready, InlineSelectBox, Select){
ready(function(){
// Add code to set the options array
var options = [];
// Add code to set the initial value
var initialValue = '';
var inlineSelect = new InlineSelectBox({
editor: Select,
editorParams: {options: options},
autoSave: true,
value: initialValue
}, "domNodeToAttachTo");
});
});