Я новичок в Backbone.js.I попытался создать коллекцию в Backbone, создав, что я получаю ошибку, так как 'd.collection is undefined error '.Получение TypeError: d.collection - неопределенная ошибка при создании коллекции в Backbone.js
$(function(){
var MyModel = Backbone.Model.extend();
var MyCollection = Backbone.Collection.extend({
url: '/index.html',
model: MyModel
});
var coll = new MyCollection();
coll.fetch({
error: function (collection, response) {
console.log('error', response);
},
success: function (collection, response) {
console.log('success', response);
}
});
});
Кроме того, мне нужно обрабатывать экспресс-результат метода маршрута в Backbone.How может я справиться с этим ..
app.js
app.all('*',function(req,res){
var result={a:'a',b:'b',c:'c'};
res.writeHead(200, {'Content-Type': 'text/json'});
res.write(JSON.stringify(result));
res.end();
});
Вы уверены, что его 'url: '/ index.html','? не должно быть 'url: '/ index.json',' – rajkamal
@rajkamal yes my url is /index.html – sachin