集合未从instagramurl获得任何响应

collection not getting any response from instagram url

本文关键字:任何 响应 instagramurl 集合      更新时间:2023-09-26

我正在从集合中的instagram url读取json数据,并在视图中获取集合数据,但没有得到任何响应。怎么了?

型号:

        define([
          'underscore',
          'backbone'
        ], function(_, Backbone) {var TopListModel = Backbone.Model.extend(return TopListModel;});

收藏:

define([
  'jquery',
  'underscore',
  'backbone',
  'models/topList/topListModel'
], function($, _, Backbone, TopListModel){
  var TopListCollection = Backbone.Collection.extend({
  model: TopListModel,
  url: 'https://api.instagram.com/v1/tags/'+hashtag+'/media/recentaccess_token='+access_code,
  });
 return TopListCollection;
});

视图:

define([
  'jquery',
  'underscore',
  'backbone',
  'text!templates/sidebar/topList.html',
  'collections/topList/TopListCollection',
  //'text!templates/home/homeTemplate.html'
], function($, _, Backbone, topList, TopListCollection){
  var TopListView = Backbone.View.extend({
    el: $("#sidebar"),
    initialize: function(){
      _.bindAll(this, 'render');
      var topListCollection = new TopListCollection();
      topListCollection.fetch({success: function(collection, data){            
        console.log(data);
      }});
      //this.render();
    },
define([
      'underscore',
      'backbone'
    ], function(_, Backbone) {var TopListModel = Backbone.Model.extend(return TopListModel;});

应该是:

define([
      'underscore',
      'backbone'
    ], function(_, Backbone) {var TopListModel = Backbone.Model; return TopListModel;});

更好的是,除非你在模型中做一些特别的事情,否则你不需要真正定义它。Backbone只会根据响应创建一个模型。