if (typeof response == "object") {
store = new dojo.data.ItemFileReadStore({
data : response
});
console.warn("Loaded to Store");
var itemArray = new Array();
var completed = function(items) {
for(var i = 0; i < items.length; i++) {
console.log(store.getValue(items[i],"itemlabel"));
itemArray.push(store.getValue(items[i]));
}
};
var error = function() {
console.log("Error in fetching data from Store");
};
store.fetch({onComplete: completed, onError: error});
console.warn("Item count"+ itemArray.length);
所以我的项目计数给出始终为0,但为什么我无法填充我的Array对象?
console.log(store.getValue(items[i],"itemlabel"));
在回调方法上得到打印的价值。
所以,如果我想填充我的itemArray
我该怎么办?
作为一个侧面说明,你不应该使用'新的Array()',而不是仅仅使用'[]'符号:'VAR itemArray = [];' – Joe 2012-02-08 13:26:58