ウィジェット ファクトリ パターンを使用して小さな jQuery ウィジェットを作成しました。ローカルでは問題なく動作しますが、コードを Heroku にプッシュすると動作しなくなります。
次のような小さなテスト アプリを作成するとします。
(function ($, undefined) {
$.ui.mytest = {
_create: function () {
alert('test');
},
destroy: function () {
// if using jQuery UI 1.8.x
$.Widget.prototype.destroy.call(this);
// if using jQuery UI 1.9.x
//this._destroy();
},
options:{}
};
$.widget("ui.mytest", $.ui.mytest);
})(jQuery);
アラートはローカルで出力されますが、実稼働環境でアセットがコンパイルされると、次のエラーが発生します。
Uncaught TypeError: Cannot read property 'length' of undefined application-2ecb4e7c4dcb5be5c5d9884cdb6c266c.js:14
Uncaught TypeError: Object [object Object] has no method 'mytest'
奇妙なことは、私が本番環境$.ui.mytest
で自分のコンソールを呼び出すことができ、それが実際に存在することです。どんな助けでも大歓迎です。