In JQuery UI, what is the correct syntax to call a super/base function? In my example below should I be calling the base function using this._super(param1)
or this._super('myFunction', param1)
?
$.widget( "namespace.Foo", {
_create: function () {
// ...
this._super( "_create" );
},
myFunction: function(param1) {
// ...
}
});
$.widget( "namespace.Bar", $.namespace.Foo, {
_create: function () {
// ...
this._super( "_create" );
},
myFunction: function(param1) {
// Is this correct?
this._super('myFunction', param1);
// or this?
this._super(param1);
// ...
}
});
This is discussed here: https://api.jqueryui.com/jQuery.widget/#method-_super
So it's already invoking
_create
in your first example, so you're now sending "_create" as an argument tothis._create()
and doesn't really do anything.Digging deeper, we see: https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/
Your first widget is not mutating, so not sure that you need to call
_super()
. In your mutation, you do not need to send an argument to_create()
. You can for the the other.