As of jQuery 1.9, a widget can inherit from itself. I couldn't find a real-world example of why this would be useful, and frankly the idea of inheriting from oneself breaks my brain. What is the purpose of this feature? What can I do using this feature that I couldn't do previously, or would've been much harder previously?
The reason is to redefine the same widget. So, you add new capabilities to it, don't needing to extend it in another object.
In the example presented in the link that you sent:
$.widget("ui.dialog", $.ui.dialog, {
close: function() {
if (confirm( "Is it closing time?" )) {
this._super("close");
}
}
});
After the execution of the code above, every dialog that is created will pop a confirm message when the user clicks in the close button and if s/he accepts it, it will close.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With