Reputation: 11
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>
Upvotes: 1
Views: 747
Reputation: 4237
First of all you should remove this code:
<!-- 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>
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.
Upvotes: 3