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

YUI Dialog: Capturing the close event

Expand Messages
  • jsmith200046
    This should be simple, but I just haven t been able to find this in the online docs: I ve created a dialog with: var myDialog = new
    Message 1 of 5 , Jan 2, 2009
    • 0 Attachment
      This should be simple, but I just haven't been able to find this in
      the online docs:

      I've created a dialog with:

      var myDialog = new YAHOO.widget.Dialog("mydialog", { modal: true });
      etc...

      I would like to do some processing if the user clicks the "X" on the
      title bar, but I can't figure out how to get that event.

      Would someone show me how to intercept that event?

      Thanks,
      Jay
    • cjavajim
      ... Perhaps it s simply a DOM issue; e.g., http://www.irt.org/script/1230.htm
      Message 2 of 5 , Jan 2, 2009
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "jsmith200046"
        <jsmith200046@...> wrote:
        >
        > This should be simple, but I just haven't been able to find this in
        > the online docs:
        >
        > I've created a dialog with:
        >
        > var myDialog = new YAHOO.widget.Dialog("mydialog", { modal: true });
        > etc...
        >
        > I would like to do some processing if the user clicks the "X" on the
        > title bar, but I can't figure out how to get that event.
        >
        > Would someone show me how to intercept that event?
        >
        > Thanks,
        > Jay
        >

        Perhaps it's simply a DOM issue; e.g., http://www.irt.org/script/1230.htm
      • Eric Miraglia
        Jay, You can listen for the hide event (inherited from the Module class): http://developer.yahoo.com/yui/docs/YAHOO.widget.Module.html#event_beforeHideEvent We
        Message 3 of 5 , Jan 2, 2009
        • 0 Attachment
          Jay,

          You can listen for the hide event (inherited from the Module class):


          We don't expose an event for hiding via the close icon specifically.  However, if you are looking for that specific action, you could do this:

          YAHOO.util.Event.on(YAHOO.util.Dom.getElementsByClassName("container-close", "a", "panel1"), "click", function() {alert("close button was clicked");});

          Replace "panel1" with the id that contains your panel.  Note that arguments 2 and 3 in the getElementsByClassName method are both optional, but the function runs much more quickly if you provide them.

          Regards,
          Eric



          On Jan 2, 2009, at 9:59 AM, jsmith200046 wrote:

          This should be simple, but I just haven't been able to find this in 
          the online docs:

          I've created a dialog with:

          var myDialog = new YAHOO.widget. Dialog("mydialog ", { modal: true });
          etc...

          I would like to do some processing if the user clicks the "X" on the 
          title bar, but I can't figure out how to get that event.

          Would someone show me how to intercept that event?

          Thanks,
          Jay


        • jsmith200046
          Thanks Eric, That was perfect! I just had to add: ...,this, true); to the end of that call and I got everything I needed. ...
          Message 4 of 5 , Jan 2, 2009
          • 0 Attachment
            Thanks Eric,

            That was perfect! I just had to add:

            ...,this, true);

            to the end of that call and I got everything I needed.

            --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...>
            wrote:

            > We don't expose an event for hiding via the close icon specifically.
            > However, if you are looking for that specific action, you could do
            this:
            >
            >
            YAHOO.util.Event.on(YAHOO.util.Dom.getElementsByClassName("container-
            > close", "a", "panel1"), "click", function() {alert("close button was
            > clicked");});
            >
            > Replace "panel1" with the id that contains your panel. Note that
            > arguments 2 and 3 in the getElementsByClassName method are both
            > optional, but the function runs much more quickly if you provide
            them.
            >
            > Regards,
            > Eric
          • morekaos
            The solution below didn t look right, kind of hokey, and at the end of the day, I could not get this to work. I searched high and low for the real solution.
            Message 5 of 5 , Oct 25, 2009
            • 0 Attachment
              The solution below didn't look right, kind of hokey, and at the end of the
              day, I could not get this to work. I searched high and low for the real
              solution. The YUI Panel/Dialog Site was not as helpful as I would have
              hoped, and the API docs defined it possible, but require one to be an expert
              in YUI syntax (which I am not).

              Eventually I found the answer that I was looking for in the YUI Cheat
              Sheets.

              The syntax to capture a close event coming off a Panel/Dialog when you click
              the X is:

              var myDlg = new YAHOO.widget.Dialog('myDialog');
              myDlg.hideEvent.subscribe( function( ){<code to execute when the
              dialog/panel closes here>};);



              jsmith200046 wrote:
              >
              > Thanks Eric,
              >
              > That was perfect! I just had to add:
              >
              > ...,this, true);
              >
              > to the end of that call and I got everything I needed.
              >
              > --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...>
              > wrote:
              >
              >> We don't expose an event for hiding via the close icon specifically.
              >> However, if you are looking for that specific action, you could do
              > this:
              >>
              >>
              > YAHOO.util.Event.on(YAHOO.util.Dom.getElementsByClassName("container-
              >> close", "a", "panel1"), "click", function() {alert("close button was
              >> clicked");});
              >>
              >> Replace "panel1" with the id that contains your panel. Note that
              >> arguments 2 and 3 in the getElementsByClassName method are both
              >> optional, but the function runs much more quickly if you provide
              > them.
              >>
              >> Regards,
              >> Eric
              >
              >
              >
              >
              >

              --
              View this message in context: http://www.nabble.com/YUI-Dialog%3A-Capturing-the-close-event-tp21254850p26051588.html
              Sent from the ydn-javascript mailing list archive at Nabble.com.
            Your message has been successfully submitted and would be delivered to recipients shortly.