グローバルアクセスのために、以下の2つの機能をどのように公開するのですか?onready関数を公開してグローバルにトリガーする方法はありますか?
私はこの中に取り掛かるだろうか、(/グローバル)第三スクリプトから関数をトリガする必要があるだろうと仮定すると、theme.handleSomething();
theme.functionWithinOnReady();
:functionWithinOnReady();
とhandleSomething();
theme
の範囲内で、私は関数をトリガすることができます一番いい方法?
(function($) {
"use strict";
var theme = {
onReady : function(){
functionWithinOnReady = function() {
//want to access this globally
}
},
handleSomething: function() {
//want to access this globally
},
onLoad : function() { },
onResize : function() { }
};
$(document).ready(theme.onReady);
$(window).load(theme.onLoad);
$(window).resize(theme.onResize);
})(jQuery);
'window.theme = {' .. [Fiddle](https://jsfiddle.net/rayon_1990/b9LLjnaL/) – Rayon