我正在布置基本结构并刚刚开始创建模型。问题是对初始化 Stackmob 的引用在模型中丢失了。
main.js
require(['modernizr','jquery','backbone', 'underscore', 'routers/router', 'stackmob'], function(Modernizr, $, Backbone, _, Router, Stackmob) {
StackMob.init({
appName: {appName},
clientSubdomain: {clientSubdomain},
apiVersion: 0
});
// Instantiates a new Router
this.router = new Router();
});
Model.js
define(['jquery', 'backbone', 'stackmob', 'models/business'], function($, Backbone, Stackmob, Business) {
var BusinessesCollection = StackMob.Collection.extend({
model: Business,
// Model Constructor
initialize: function() {
}
});
// Returns the Model class
return BusinessesCollection;
});
如何让模型模块可以访问已初始化的 StackMob 对象?