Open pubmikeb opened 8 hours ago
didn't work until I've added
controller: this
Better replace sap.ui.xmlfragment
with this.loadFragment
, as shared in "Methods assigned in XML fragment not triggered" - Stack Overflow, if this
can be referred to a Controller instance which becomes the event listener of the fragment automatically.
API reference: sap/ui/core/mvc/Controller#loadFragment
Better replace
sap.ui.xmlfragment
withthis.loadFragment
Then, there is no need for an extra call of sap.ui.require
with loading of sap/ui/core/Fragment
!
Then perhaps it's better to mention in the documentation that this.loadFragment
is the preferable alternative over sap.ui.core.Fragment.load
to replace sap.ui.xmlfragment
.
Currently, there is no single word regarding this.loadFragment
in the sap.ui.xmlfragment
-section.
While doing a codebase refactoring to get rid of the legacy UI5 APIs, I've faced a need to replace
sap.ui.xmlfragment
with the modern, async API —sap.ui.core.Fragment.load
.In the
sap.ui.core.Fragment
-documentation, I've found several snippets how to use this API, e.g.:In my case, this snippet didn't work until I've added
controller: this
, following the @boghyon's advice on SO.In the API documentation, there is a mention of the
controller
property:Since in some circumstances the code won't work without the
controller
-property, wouldn't be better to pay more attention to this property in this API's documentation, providing a code snippet and more detailed explanation when and why this property might be necessary, rather than just mentioning «some Fragments may not need a Controller while others may need one»?