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:
#!js var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog"); oDialogFragment.open();
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:
#!js var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog"); oDialogFragment.setModel(this.getView().getModel()); oDialogFragment.open();
#!js var oDialogFragment = sap.ui.jsfragment("testdata.fragments.JSFragmentDialog"); this.getView().addDependent(oDialogFragment); oDialogFragment.open();