I'm not sure if I'm doing things quite right with jqModal (the docs are 
rather sparse).  What I'm having a problem with is opening a dialog box 
(ajax call), and applying a click event handler to my "save" link.  This 
sometimes works, and sometimes not.  Even with a timer added, the 
handler sometimes is not applied, regardless of the timeout value I use. 
  So I'm looking for a better way, or the bug in my routine....  Here's 
my code:

$("#dialogOrg").jqm({
     ajax: "dialogs/org.htm?r=" + Math.random(),
     trigger: "#newOrg",
     target:"#dialogOrgContent",
     modal: true,
     overlay: 75,
     onShow : function (hash) {
       hash.w.css('width',400).show();
       //we have a timing problem.  Trying to set the event handler 
right away would fire before the
      //#orgSave element was loaded.  So we introduce a small artificial 
delay to help with this.
       setTimeout(function () {
         $("#orgSave").unbind("click").click(function () {
           var p = $("#frmOrg").serialize();
           $.ajax({
             type: "POST",
             url: "xhr/orgSave.php",
             data: $("#frmOrg").serialize(),
             dataType: "json",
             error: function (a,b,c) {
             alert("HERE");
               $("#frmOrg .message").hide().html("<h3>Error</h3>" + 
a.responseText).slideDown();
             },
             success: function () {
               listOrganizations();
               //hide the dialog
               $("#dialogOrg").jqmHide();
             }
           });
           return false;
         });
       }, 100);
     }
   });

Any tips or glaring holes??  Thanks.

Shawn

Reply via email to