当前位置: 动力学知识库 > 问答 > 编程问答 >

json - Backbone.js collector data missing

问题描述:

I have this simple JSON feed which I am attempting to read in a BackBone.JS app.

My challenge is the network traffic comes up completely blank as illustrated below:

Using the following code:

 //Collections

var Topics = Backbone.Collection.extend({

model: TopicStruct,

initialize: function(){

console.log('Collector Responding!');

},

url: 'http://dev-sw-budget.gotpantheon.com/sort-coordinator-json',

render: function(){

console.log('Topics Render Responding!');

},

});

Can anyone help clarify why I'm not getting my data in my Backbone app, please?

UPDATE:

My fetching code:

$(document).ready(

function(){

console.log('--- DOM Ready!');

var topics = new Topics();

var topicsView = new TopicsList({collection: topics});

topics.fetch({reset: true});

$('#data table').append(topicsView.el);

}

);

网友答案:

I think the problem it's that you are not calling fetch() in your collection. I have put your code together in a JSFiddle and it works.

var topics = new Topics();
topics.fetch();
分享给朋友:
您可能感兴趣的文章:
随机阅读: