Showing results for 
Search instead for 
Did you mean: 

sap.m.Page open dialog after routing

Former Member
0 Kudos


Having some trouble opening a Dialog after navigating to a page. The intention is to always open the dialog when a user lands on this page.

Simplified, I have a controller that looks like this:

onInit: function() {}

  this.myRouter.getRoute("orderscreate").attachPatternMatched(this._onObjectMatched, this);


_onObjectMatched: function() {

  this.dialog = sap.ui.xmlfragment("myDialog", this);;


When I put a debugger in, this works great, I can see the dialog is open.

THEN, the navigation animation kicks in, does the slide animation, and upon completion the dialog is closed again. I'm not sure why it insist on navigating after the view has rendered.

This happens when using navTo as well. Dialog opens, animation starts, dialog is closed again. sap.m.Page does not have another way of executing code after showing, as far as I'm aware.

Any advice?

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

Hi Jorg,

May be there is no enough time to display the dialog. Add a delayed call with 0 seconds, this seems to work.

var that = this;, null, function() {

    if (!that._oDialog) {

        that._oDialog = sap.ui.xmlfragment("sap.ui.demo.wt.Dialog", that);




And one more thing is if we place this piece of code in onInit, it hits only once. But rather if you want to display each time you navigate to this page, then you may have to use View's onBeforeShow event inside onInit, something like this:

onInit: function(){

     var that = this;

     var oView = that.getView();


          onBeforeShow: function(){

          //Place the above code here..


}, oView);


Will this sample help? Dialog Open. Check Detail.controller.js file for code.


Sai Vellanki.