Most docs on the init method of UI5 components mention to call the superclass' init method when overwriting it:
sap.ui.commons.Button.prototype.init.apply(this, arguments);
But this is not working. When debugging sap.ui.commonds.Button and analyzing its prototype, there's no init method present - so of course apply fails.
Am I doing anything wrong or is this a deprecated approach?
From the UI5 documentation:
If you inherit from another control that has (or might get) an init() method, you need to explicitly call it...
Since the Button control has no init() function so far (but can exist in future versions) I would do it like this to be future safe:
if (sap.ui.commons.Button.prototype.init) { // check whether superclass has an init() method
sap.ui.commons.Button.prototype.init.apply(this, arguments); // call super.init()
}
Hope this helps you.
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