dojo 自动填充示例不起作用
我从道场网站上得到了这个例子。但这对我不起作用。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<script type="text/javascript">
dojo.addOnLoad(function() {
var stateStore = new dojo.data.ItemFileReadStore({
url: "../../_static/js//dijit/tests/_data/states.json"
});
var filteringSelect = new dijit.form.FilteringSelect({
id: "stateSelect",
name: "state",
value: "KY",
store: stateStore,
searchAttr: "name"
},
"stateSelect");
});
</script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
/>
</head>
<body class=" claro ">
<input id="stateSelect">
<p>
<button onClick="alert(dijit.byId('stateSelect').get('value'))">
Get value
</button>
<button onClick="alert(dijit.byId('stateSelect').get('displayedValue'))">
Get displayed value
</button>
</p>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
dojo.addOnLoad(function() {
if (document.pub) {
document.pub();
}
});
</script>
</body>
I have got this example from the dojo site. However this is not working for me.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<style type="text/css">
body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<script type="text/javascript">
dojo.addOnLoad(function() {
var stateStore = new dojo.data.ItemFileReadStore({
url: "../../_static/js//dijit/tests/_data/states.json"
});
var filteringSelect = new dijit.form.FilteringSelect({
id: "stateSelect",
name: "state",
value: "KY",
store: stateStore,
searchAttr: "name"
},
"stateSelect");
});
</script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"
/>
</head>
<body class=" claro ">
<input id="stateSelect">
<p>
<button onClick="alert(dijit.byId('stateSelect').get('value'))">
Get value
</button>
<button onClick="alert(dijit.byId('stateSelect').get('displayedValue'))">
Get displayed value
</button>
</p>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
dojo.addOnLoad(function() {
if (document.pub) {
document.pub();
}
});
</script>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您应该删除此代码:
第二个问题是填充 ItemFileReadStore。您的网站上真的有这个文件
"../../_static/js//dijit/tests/_data/states.json"
吗?如果没有,您应该创建它(或修复文件路径)或使用其他方法来填充 ItemFileReadStore。First of all you should remove this code:
And the second problem is populating ItemFileReadStore. Do you really have this file
"../../_static/js//dijit/tests/_data/states.json"
on your site ? If no, you should create it(or fix file path) or use another method to populate ItemFileReadStore.