Loading ...
Sorry, an error occurred while loading the content.

Trouble with Dialog

Expand Messages
  • douloscristou
    I am really struggling to wrap my arms around what s going on. I am creating a dialog in my application and not understanding why it is not consistently
    Message 1 of 2 , Aug 26, 2009
    • 0 Attachment
      I am really struggling to wrap my arms around what's going on. I am creating a dialog in my application and not understanding why it is not consistently working as expected. The first time my code runs, everything works correctly. The second time it runs, I cannot move it on the screen (every other attribute seems to be working).

      The function I am using to create the object follows:

      appData.createDialog=function(){
      appData.dialog = new YAHOO.widget.Dialog("dialog", {
      width : '600px',
      fixedcenter : true,
      visible : false,
      constraintoviewport : true
      });

      appData.dialog.render();
      appData.dialog.show();
      }

      Before I call the function, I dynamically create the content for the "dialog" div and then call appData.createDialog();

      As I said, the first time this works great and the second time it almost works but just does not function properly (will not move on the screen). I have tried different approaches but the results were even worse.

      For instance, I removed appData.dialog.render() and appData.dialog.show() from the createDialog() function. My function that creates the content for "dialog" div, called appData.createDialog() only if appData.dialog did not already exist, and then called the render and show functions. For some reason this removed the header altogether (the title and x) on the second run (again, everything worked correctly on the first run).

      I'm sure I've got to be missing something simple, but I just can't figure out where I'm going wrong. I seem to be saying this a lot in this forum, but any push in the right direction would be greatly appreciated.
    • Ken Loomis
      ... I don t know the finer points of YUI. that s for sure, but I use the dialogs a lot. I create the dialog as part of my page rendering. So the appDialog =
      Message 2 of 2 , Aug 28, 2009
      • 0 Attachment
        douloscristou wrote:
        > I am really struggling to wrap my arms around what's going on. I am creating a dialog in my application and not understanding why it is not consistently working as expected. The first time my code runs, everything works correctly. The second time it runs, I cannot move it on the screen (every other attribute seems to be working).
        >
        > The function I am using to create the object follows:
        >
        > appData.createDialog=function(){
        > appData.dialog = new YAHOO.widget.Dialog("dialog", {
        > width : '600px',
        > fixedcenter : true,
        > visible : false,
        > constraintoviewport : true
        > });
        >
        > appData.dialog.render();
        > appData.dialog.show();
        > }
        >
        > Before I call the function, I dynamically create the content for the "dialog" div and then call appData.createDialog();
        I don't know the finer points of YUI. that's for sure, but I use the
        dialogs a lot. I create the dialog as part of my page rendering. So the
        appDialog = new YAHOO.widget.Dialog goes in the init for the page along
        with the appData.dialog.render(). Then when you want to show it, you do
        the appData.dialog.show();

        If you repeatedly call the appDataDialog in your app, you going to be
        creating the same element over and over again, and you would have to
        destroy it each time you closed it, and it would have to be modal to
        prevent you from opening another one while the first is still open. So
        just create and render it once in your page init, and then show it and
        close it as needed.

        HTH

        KEn
      Your message has been successfully submitted and would be delivered to recipients shortly.