我看不出有什么问题,但错误控制台显示:“_21.store.fetch 不是函数”。组合框只是没有被填充。我尝试了 Memory 和 ItemFileWriteStore,两者都不起作用!怎么了?我正在使用 dojo 1.6.1 顺便说一句。代码如下:
<html>
<head>
<script type="text/javascript" src="dojo/dojo.js.uncompressed.js"></script>
<link rel="stylesheet" type="text/css" href="dojo/resources/dojo.css"></style>
<link rel="stylesheet" type="text/css" href="dijit/themes/claro/claro.css"></style>
<script type="text/javascript">
dojo.require("dijit.form.ComboBox");
dojo.require("dojo.store.Memory");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<script type="text/javascript">
dojo.ready(function(){
var rateStore, rate;
rateStore = new dojo.store.Memory({
data: [
{id:1, name:"1 X"},
{id:2, name:"2 X"},
{id:4, name:"4 X"},
{id:6, name:"6 X"},
{id:8, name:"8 X"},
{id:10, name:"10 X"}
]
});
/*
rateStore = new dojo.data.ItemFileWriteStore({
data: {
items:[
{id:1, name:"1 X"},
{id:2, name:"2 X"},
{id:4, name:"4 X"},
{id:6, name:"6 X"},
{id:8, name:"8 X"},
{id:10, name:"10 X"}
]
}
});
*/
rate = new dijit.form.ComboBox({
id: "rate",
name: "rate",
store: rateStore,
searchAttr: name,
style: "width:50px"
}, dojo.byId("rate"));
rate.startup();
});
</script>
</head>
<body class="claro">
<div id="rate"></div>
</body>
</html>