on 2022 Nov 04 8:49 AM
Hi All!
I am following the walk through in UI5 website!
currently i am in fragmetns and dialog , fragment callback step.
The dialog opens but the text content of the dialog is not visible!
Could anyone please help me wit this!
i18n
dialogText= {1}
dialogCloseButtonText= close<br>
fragment
<core:FragmentDefinition xmlns="sap.m"
xmlns:core="sap.ui.core">
<Dialog id="helloDialog"
title="Hello {/recipient/text}"
>
<content>
<core:Icon src="sap-icon://hello-World"
size="8rem"
class="sapUiMediumMarin"/>
</content>
<beginButton>
<Button text="{i18n>dialogCloseButtonText}"
press=".onCloseDialog" />
</beginButton>
</Dialog>
</core:FragmentDefinition><br>
controller.js
onOpenDialog: function() {
// Walkthrough Dialog
if(!this.pDialog){
this.pDialog = Fragment.load({
name:"zproject.fragment.Dialog",
});
}
this.pDialog.then(function(oDialog){
oDialog.open();
});
},
onCloseDialog: function(){
this.byId("helloDialog").close();
}<br>
Request clarification before answering.
onOpenDialog: function() {
// Walkthrough Dialog
var that=this
if(!this.pDialog){
this.pDialog = Fragment.load({
name:"zproject.fragment.Dialog",
});
}
this.pDialog.then(function(oDialog){
that.getView().addDependent(oDialog);
oDialog.open();
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Fragment.load({
name:"zproject.fragment.Dialog",
controller:this
});
Hi Jun Wu!
First of all Thank you so much for the instant replies!
Actually after adding this controller:this the event onCloseDialog getting triggered atleast.
The problem now is i amgetting this error in console!
Uncaught TypeError: Cannot read properties of undefined (reading 'close')
at f.onCloseDialog.
Which version of UI5 Walkthrough are you following? The latest stable version page, the newer API sap.ui.core.mvc.Controller#loadFragment is used instead of the old sap.ui.core.Fragment.load. With the loadFragment API, adding the fragment (dialog) to the view's dependent aggregation is already taken care of as well as assigning the controller as the event listener (plus assigning the owner-component ID via runAsOwner but that's a different topic).
onOpenDialog: function () {
if (!this.pDialog) {
this.pDialog = this.loadFragment({
name: "sap.ui.demo.walkthrough.view.HelloDialog"
});
}
this.pDialog.then(function(oDialog) {
oDialog.open();
});
},
Related Q&A which might be helpful:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
33 | |
9 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.