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

Re: How to make a Dialog that returns a value?

Expand Messages
  • bretlevy
    I don t have an exact example for you, but I do something similar that I think you can extend to create a model for dialogs that return a value. In my case, I
    Message 1 of 4 , Aug 31 9:03 AM
    • 0 Attachment
      I don't have an exact example for you, but I do something similar
      that I think you can extend to create a model for dialogs that return
      a value. In my case, I have "generalized" popup windows into basic
      classes (alerts, confirms, etc). A confirm-style popup is siply a
      simple dialog that "returns" yes or no (in my case, I don't care
      about "no", so it really only returns "yes".)

      So when I want to display a confirm popup, I call the following (yes,
      global) function:

      function YConfirm (msg, yeshandler) {
      popupMessageBox ('Please Confirm...', msg,
      YAHOO.widget.SimpleDialog.ICON_WARN, [{label:'Yes',func:function()
      {popupMessageBoxHide();yeshandler();}},
      {label:'No',func:popupMessageBoxHide}]);
      }

      It calls the general purpose function:

      var popupInit = true;
      var popupMessageBoxForm;

      function popupMessageBox (title, message, icon, buttons) {

      if (!YAHOO.util.Dom.inDocument('popupMessageBoxContainer'))
      return;

      // create the dialog

      var ybuttons = [];
      for (var i=0; i<buttons.length; i++) {
      ybuttons[i] = { text:buttons[i].label, handler:buttons
      [i].func, isDefault:(i==0?true:false) };
      }

      if (popupInit) {

      popupInit = false;

      popupMessageBoxForm = new YAHOO.widget.SimpleDialog
      ("popupMessageBoxContainer", {
      modal: true,
      width: "300px",
      fixedcenter: true,
      visible: false,
      draggable: false,
      close: true,
      text: message,
      icon: icon,
      constraintoviewport: true,
      buttons: ybuttons,
      zIndex: 5000
      });

      }

      else {

      popupMessageBoxForm.cfg.setProperty ("icon", icon);
      popupMessageBoxForm.setBody (message);
      popupMessageBoxForm.cfg.setProperty ("buttons", ybuttons);

      }

      popupMessageBoxForm.setHeader(title);
      popupMessageBoxForm.render(document.body);
      popupMessageBoxForm.show();

      }

      function popupMessageBoxHide () {
      popupMessageBoxForm.hide();
      }

      I don't see why you can't create a more complex dialog that "calls
      out" to a "handler" function with the value(s) you which
      to "return". Each exit path of the dialog could "point" to the same
      handler and pass a flag indicating the path ("save", "cancel", etc,
      etc).

      Hope that helps...

      ~~bret



      --- In ydn-javascript@yahoogroups.com, "Mark Ian Tilog"
      <micro_mark_ian@...> wrote:
      >
      > any example with this plsss?
      > Thanks for the reply...
      >
      > --- In ydn-javascript@yahoogroups.com, "Chris Curran"
      > <curran.chris@> wrote:
      > >
      > > Use a custom event?
      > >
      > > --- In ydn-javascript@yahoogroups.com, "Mark Ian Tilog"
      > > <micro_mark_ian@> wrote:
      > > >
      > > > i need an dialog that returns a value...
      > > >
      > > > anyone can help me with this?
      > > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.