我正在尝试查询分析表,并且能够获取数据。然后,我将这些数据传递给Parse视图,以便将其渲染到车把模板中。当我手动将JSON数据输入到集合变量中时,视图本身正在工作。无法传递查询结果以查看并呈现为JSON
我的问题是,数据没有从查询传递到视图或没有转换为JSON。我不断收到以下错误:
Uncaught TypeError: this.collection.toJSON is not a function
// render template with context data
var StoresView = Parse.View.extend({
template: Handlebars.compile($('#storetable-tpl').html()),
render: function(){
var collection = { storeList: this.collection.toJSON() };
this.$el.html(this.template(collection));
}
});
// query the store table data
allStores.equalTo("shape","Round");
allStores.limit(10);
allStores.descending("updatedAt");
allStores.find({
success: function(results) {
var storesView = new StoresView({ collection: results });
storesView.render();
$('#stores-table').html(storesView.el);
}
});
我在做什么错?
我只注意到,这些问题是不是从查询,查看传递数据。当我更改'code'var集合= {storeList:this.collection};然后我得到数组中的数据。 – Rahul