I read in the link that we can have event handler when a jQuery UI widget is created using on.
https://api.jqueryui.com/jquery.widget/#event-create
$( ".selector" ).on( "widgetcreate", function( event, ui ) {} );
But when I tried in the JSFiddle like below, it doesn't work.
$.widget( "my.customwidget", {
_create: function() {
alert('Hi!');
}
});
$('#widget').on('widgetcreate', function (event, ui) {
alert('Hi again!');
});
$('#widget').customwidget();
The alert('Hi again!') doesn't get executed. Here's the fiddle.
Unless I do this.
$.widget( "my.customwidget", {
_create: function() {
this.element.trigger('widgetcreate');
}
});
What did I do wrong?
myhere? is that anyelement?namespaceaccording to jQuery UI