Hello Folks,
I am working on XP with Zend 1.7.1.
I am trying to get data from Database into a Dojo Combobox on my form -
transfering the data using JSON.
I have the following Javascript on my phtml
<script type="text/javascript">
dojo.addOnLoad(function(){
var pfStore = new dojo.data.ItemFileReadStore({url: "/test/games"});
var cb1 = new dijit.form.ComboBox({id: "platforms", name: "pf2", value:
"Xbox", store: pfStore, searchAttr: "name"}, "platforms");
});
</script>
and the following html snippet
<td><input id="platforms"></td>
When I click on the downarrow on the combobox, I see in FireBug the query
going out to /test/games but then it gives the following error
"dijit.form.ComboBox: TypeError: this._arrayOfTopLevelItems is undefined"
I look at the response in Firebug and I get the following JSON string.
[{"id":"1","name":"XBox"},{"id":"2","name":"XBox
360"},{"id":"3","name":"Sony PSP"},{"id":"4","name"
:"Playstation 3"},{"id":"5","name":"Playstation 2"},{"id":"6","name":"PC
Games"},{"id":"7","name":"Nintendo
Wii"},{"id":"8","name":"GameCube"},{"id":"9","name":"Nintendo
DS"},{"id":"10","name":"Nintendo GBA"
}]
To get this JSON, on the server side I do a fetchAll()->toArray() and then
apply Zend_Json::encode
I don't understand what causes the error and why the "names" in response
data don't show up in my ComboBox. Sounds like I am overlooking something
simple/basic here.
Appreciate any help/pointers.
-S
--
View this message in context:
http://www.nabble.com/Getting-JSON-data-in-ComboBox-gives-error-tp21882849p21882849.html
Sent from the Zend Framework mailing list archive at Nabble.com.