【发布时间】:2012-05-21 02:17:14
【问题描述】:
如何获取函数外数组的所有内容?
$.each(Basepath.Templates, function(i){
templateArray = new Array({title: Basepath.Templates[i].Template.name, src: 'view/'+Basepath.Templates[i].Template.id, description: Basepath.Templates[i].Template.name});
});
console.log(templateArray); //contains only one array;
编辑:
这是我想要的输出
templateArray[
{
title: "one",
src: "view/1",
description: "Descrption 1"
},
{
title: "two",
src: "view/2",
description: "Descrption 2"
},
{
title: "one",
src: "view/3",
description: "Descrption 3"
}
]
【问题讨论】:
-
templateArray = new Array当然是一个数组有什么问题? -
总之,它太本地化了。
标签: javascript jquery arrays