0

我有以下代码:

应用程序.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 ($) 未定义?

4

1 回答 1

1

最明显的猜测:jQuery 还没有加载。可能是以错误的顺序添加脚本引用,或者在加载 jQuery 之前执行此特定代码。

于 2013-10-04T17:21:32.357 回答