我正在使用 dojo 1.7 进行开发并遇到错误。我的目标是将项目从一个多选框移动到另一个。页面很长,所以我只复制了相关部分。
这是我的头部 js 代码,问题出现在 dojo.ready 之后。变量“newStore”很好用,所以我知道它执行得很好。似乎是 dojo.query("button.switch") 问题。我得到的萤火虫错误是
dojo.query("button.switch").connect is not a function
页面加载时会引发此错误。代码是……
<script type="text/javascript">
require(["dijit/dijit"]);
require(["dojo/parser"]);
require(["dijit/layout/BorderContainer"]);
require(["dijit/layout/ContentPane"]);
require(["dijit/layout/AccordionContainer"]);
require(["dijit/layout/TabContainer"]);
require(["dijit/form/CheckBox"]);
require(["dijit/form/Button"]);
require(["dijit/form/ComboBox"]);
require(["dijit/form/NumberTextBox"]);
require(["dijit/form/SimpleTextarea"]);
require(["dijit/form/TextBox"]);
require(["dijit/form/Textarea"]);
require(["dijit/form/MultiSelect"]);
require(["clipart/ArrowLeft"]);
require(["clipart/ArrowRight"]);
require(["dijit/form/FilteringSelect"]);
require(["dijit/form/RadioButton"]);
require(["dijit/form/Select"]);
require(["dojox/layout/GridContainer"]);
require(["dojo/data/ItemFileReadStore"]);
require(["dijit/Tree"]);
require(["dojo/ready"]);
dojo.ready(function(){
var newStore = new dojo.data.ItemFileReadStore({
url: "http://0:3000/sample/sample_name"
});
dijit.byId('sc_sample_name').set('store',newStore);
dojo.query("button.switch")
.connect("onclick",function(e){
switch(e.target.id.toString()){
case "left" : dijit.byId("at2").addSelected(dijit.byId("at1")); break;
case "right" : dijit.byId("at1").addSelected(dijit.byId("at2")); break;
}
});
});
</script>
这是一个页面加载问题,这就是为什么我不包括 HTML(这是巨大的)。有没有人见过这种行为?珍妮