jqplotを requireJS モジュールとして読み込もうとしています。
私main.js
のパスとシムは次のようになります。
require.config({
, paths: {
plot: '../js/plugins/jqplot/jqplot.module'
}
, shim: {
'plot': { deps: ['jquery']}
}
});
このモジュールはほとんどのページで必要ないため、pageXYZがロードされるのを待ってから、 a 内で<script></script>
呼び出しています:
require(['plot'],
function (plot) {
// do stuff
}
);
そして、私は次のようにjqplot.module
見えます:
define(['../js/plugins/jqplot/jquery.jqplot'],
function () {
require([
'../js/plugins/jqplot/plugins/jqplot.barRenderer'
, '../js/plugins/jqplot/plugins/jqplot.logAxisRenderer'
, '../js/plugins/jqplot/plugins/jqplot.categoryAxisRenderer'
, '../js/plugins/jqplot/plugins/jqplot.canvasAxisTickRenderer'
, '../js/plugins/jqplot/plugins/jqplot.canvasTextRenderer'
, '../js/plugins/jqplot/plugins/jqplot.pointLabels'
, '../js/plugins/jqplot/plugins/jqplot.enhancedLegendRenderer'
],
function (){
return $.jqplot;
}
);
}
);
すべてのサブプラグインが定義され、使用可能な正しいオブジェクトを返します。
ただし、Do stuff code runs BEFORE jqplot
is assigned to$
であるため、コードを実行すると未定義のエラーが引き続き発生します(ファイルがすべてロードされているため、requirejs の実行が開始されると思います)。
質問:
jqplot が $ に割り当てられるまで、コードの実行を停止するにはどうすればよいですか?