Show TOC

Using Dialogs Defined as FragmentsLocate this document in the navigation structure

The fragment instantiation function always returns the fragment's root control, which is a dialog control that can be used like any dialog.


In the following example, the dialog is opened immediately:

var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog");;

Note that any global model is available for data binding within this dialog. Also any model set on the dialog itself. However, if this dialog is opened from a controller, the model of this controller's view is NOT automatically available within the dialog fragment. The reason for this is that the dialog is not part of the view UI. If the above code for opening the fragment dialog is part of a controller, it could set the view's model on the dialog:

var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog");
Alternatively, the special aggregation dependents of sap.ui.core.Element can be used to connect the dialog to the lifecycle management and data binding of the view:
var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog");