I'm having troubles binding to the 'create' event of the widget that uses jQuery UI Widget Factory. It only happens if I'm binding to it outside the widget. Please see the snippet (simplified for testing purposes)
(function($){
$.widget('pr.test', {
options: {
create: function(e){
// Shows up in the console
console.log('Widget created');
}
}
});
})(jQuery);
And then later in some other file I'm binding to this event
jQuery(document).ready(function($){
$('body').test().on('testcreate', function(){
// Doesn't show up in the console
console.log('Widget created');
});
});
I'm aware that I could just do this
$('body').test({
create: function(){
console.log('Widget created')
}
});
but I need to be able to bind to the event multiple times after the widget initalization. Can somebody please explain what the problem is? Thanks.