I am trying to decompose a large HTML view down into smaller, more manageable chunks.
Is it possible to use fragments to do this?
For example, I have a fragment file (view.configurator.Summary.fragment.html) containing the following:
<div data-sap-ui-type="sap.m.Button" data-text="Hello"></div>
In my parent file, I try to include the fragment as follows:
<div data-sap-ui-type="sap.m.VBox" class="summary-panel-content">
<div data-sap-ui-type="sap.ui.core.Fragment"
data-fragment-name="view.configurator.Summary"
data-type="HTML"></div>
</div>
However I get the following Error in the console:
Please provide a fragment name
Any ideas?
Seems like its a bug, but you can workaround by wrapping the fragment in a custom control
sap.ui.core.Control.extend("sap.mic.controls.Fragment", {
metadata: {
properties: {
"name": "string"
}
},
init: function () {
},
renderer: function (renderManager, control) {
var fragmentName = control.getProperty("name"),
fragment = sap.ui.htmlfragment(fragmentName);
renderManager.renderControl(fragment);
}
});
And used like so:
<div data-sap-ui-type="sap.m.Page" data-enable-scrolling="false">
<div data-sap-ui-type="sap.mic.controls.Fragment"
data-name="view.configurator.Summary"></div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…