3

I am trying to display a ModalDialog as soon as the window gets loaded, something like a license agreement for my app. It seems to work fine when triggered with a button click, but does not work when I try this:

This is in the components array of my VFlexBox kind:

{ name: "theDialog", kind: "ModalDialog", components: [
    { content: "This is a Dialog Box" },
    { layoutKind: "HFlexLayout", pack: "center", components: [
    { name: "okayButton", kind: "Button", caption: "Okay" },
    { name: "closeButton", kind: "Button", caption: "Close" }
    ]}
]}

And this is where I'm trying to show the dialog.

create: function() {
   this.inherited(arguments);
   this.$.theDialog.openAtCenter();
}

If I placed the this.$.theDialog.openAtCenter(); inside the handler of a Button's onclick event, it works absolutely fine.

Bhakta Nall
  • 194
  • 1
  • 10

1 Answers1

5

Have you tried placing the this.$.theDialog.openAtCenter(); inside the rendered()

Something like this:

rendered: function() {
     this.$.theDialog.openAtCenter();
}

Since the type is "Control" rendered should be called when the UI element is created and hence openAtCenter should be called.

Vivek
  • 680
  • 1
  • 12
  • 24
  • That worked wonderfully. However, I have changed the logic of my application so it no longer needs to do it. I'll remember this, though. – Bhakta Nall Sep 03 '11 at 03:22