我有以下代码:
app.js
var AgencyUI = new Marionette.Application();
AgencyUI.addRegions({
gridRegion: "#gridRegion"
});
AgencyUI.on("initialize:after", function() {
AgencyUI.trigger("grid:loadGrid");
});
grid_app.js
AgencyUI.module('GridApp', function(GridApp, AgencyUI, Backbone, Marionette, $, _) {
var API = {
loadGrid: function(dateRange) {
GridApp.Show.Controller.loadGrid(dateRange);
}
};
AgencyUI.on("grid:loadGrid", function(dateRange) {
API.loadGrid(dateRange);
});
});
show_controller.js
AgencyUI.module('GridApp.Show', function(Show, AgencyUI, Backbone, Marionette, $, _) {
Show.Controller = {
loadGrid: function(dateRange) {
// undefined
console.log($);
}
};
});
为什么jQuery($)未定义?
答案 0 :(得分:1)
最明显的猜测:jQuery还没有加载。也许脚本引用以错误的顺序添加,或者在加载jQuery之前执行此特定代码。