jQuery UI Widget Factory を使用するウィジェットの「作成」イベントへのバインドに問題があります。ウィジェットの外でバインドしている場合にのみ発生します。スニペットを参照してください (テスト用に簡略化されています)
(function($){
$.widget('pr.test', {
options: {
create: function(e){
// Shows up in the console
console.log('Widget created');
}
}
});
})(jQuery);
そして後で、このイベントにバインドしている他のファイルで
jQuery(document).ready(function($){
$('body').test().on('testcreate', function(){
// Doesn't show up in the console
console.log('Widget created');
});
});
私はこれを行うことができることを知っています
$('body').test({
create: function(){
console.log('Widget created')
}
});
しかし、ウィジェットの初期化後にイベントに複数回バインドできる必要があります。誰かが問題が何であるかを説明できますか? ありがとう。