cancel
Showing results for 
Search instead for 
Did you mean: 

The text content in the dialog in invisible!

0 Kudos
354

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>

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos
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(); }); },
0 Kudos

Thank you Jun Wu!

Now I am getting the text content.

but the close function isn't working.

Any idea?

Thanks in advance!

junwu
Active Contributor
Fragment.load({
					name:"zproject.fragment.Dialog",
controller:this });
0 Kudos

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.

junwu
Active Contributor
0 Kudos
sap.ui.getCore().byId("helloDialog").close();

Answers (1)

Answers (1)

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

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:

0 Kudos

Hi boghyon.hoffmann!

Than You!