这些最后几天我在玩Backbone.
我想从twitter搜索API接收一些数据.但我真的不明白它是如何运作的.这是我的代码:
(function($){
Tweet = Backbone.Model.extend();
Tweets = Backbone.Collection.extend(
{
model: Tweet,
url: 'http://search.twitter.com/search.json?q=Hamburg&rpp=5&lang=all&callback=?',
parse: function(response)
{
return response.results;
}
});
DefaultTweetView = Backbone.View.extend(
{
initialize: function(){
_.bindAll(this, 'render');
}
template: _.template('<p>@<%= from_user %> <em></em></p><p><%= text %></p><p><%= location %></p>'),
render: function()
{
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
app = new Tweet();
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
我认为这不对.但我不知道如何处理它:(有人可以帮助我或发布链接,我可以遵循一些关于json数据和主干的说明吗?