【发布时间】:2013-08-30 18:16:35
【问题描述】:
我正在尝试使用backbones.js fetch 从推特搜索中获取json
下面的代码有人能告诉我哪里出错了吗?
(function($){
var Item = Backbone.Model.extend();
var List = Backbone.Collection.extend({
model: Item,
url:"http://search.twitter.com/search.json?q=blue%20angels&rpp=5&include_entities=true&result_type=mixed"
});
var ListView = Backbone.View.extend({
el: $('#test'),
events: {
'click button#add': 'getPost'
},
initialize: function(){
_.bindAll(this, 'render', 'getPost');
this.collection = new List();
this.render();
},
render: function(){
var self = this;
$(this.el).append("<button id='add'>get</button>");
},
getPost: function(){
console.log(this.collection.fetch());
}
});
// **listView instance**: Instantiate main app view.
var listView = new ListView();
})(jQuery);
我刚刚开始使用骨干网,我只想控制台记录 json
您可以在此处查看我的示例。 jsfiddle.net/YnJ9q/2/
【问题讨论】:
标签: json backbone.js