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

Re: Problem submitting form with SimpleDialog

Expand Messages
  • mattatlamplight
    Puzzling. It sounds like there s a scope problem - that this in the handleSubmit function isn t the dialog object... But without playing with it it looks like
    Message 1 of 4 , May 5 8:10 AM
    • 0 Attachment
      Puzzling. It sounds like there's a scope problem - that this in the handleSubmit function isn't the dialog object... But without playing with it it looks like it ought to work.

      At this point I'd try alert(this); in your handleSubmit function before the submit() call, or put in some breakpoints in Firebug and see if you can tell what the scope is when the function gets called.

      Sorry not more help.

      Matt

      --- In ydn-javascript@yahoogroups.com, "lemoserges" <lemoserges@...> wrote:
      >
      > Thanks Matt,
      > I changed it to Dialog, but there seems to be a problem with the submit function. Here is my new Javascript function below. Now when I click on Submit, it does not seem to do anything. I get the alert "I am in submit", but I never get the alert "I am leaving submit" and the overlay stays put.
      >
      > I checked in Firebud and there is no error. This is really a head scratcher..
      >
      > <script type="text/javascript">
      > function showSurvey() {
      > var Event = YAHOO.util.Event,
      > Dom = YAHOO.util.Dom; Event.onDOMReady(function () {
      > // Define various event handlers for Dialog
      > var handleSubmit = function() { alert("I am in submit");
      > this.submit(); alert("I am leaving submit");
      > };
      > // Define various event handlers for Dialog
      > var handleCancel = function() {
      > this.hide();
      > };
      > // Define events for successful survey
      > var handleSuccess = function(o) {
      > alert("Thank you");
      > };
      > var handleFailure = function(o) {
      > alert("Submission failed");
      > };
      > var oPanel3 = new YAHOO.widget.Dialog("survey_overlay", {
      > width : "30em", fixedcenter : true,
      > modal: true,
      > visible : true,
      > constraintoviewport : true,
      > postmethod: "form",
      > buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
      > { text:"Cancel", handler:handleCancel } ]
      > });
      > // Wire up the success and failure handlers
      > oPanel3.callback = { success: handleSuccess, failure: handleFailure };
      > oPanel3.setHeader("Quick survey");
      > oPanel3.render();
      > });
      > }</script>
      >
      >
      >
      > --- In ydn-javascript@yahoogroups.com, "mattatlamplight" <matt@> wrote:
      > >
      > > Hi,
      > >
      > > I've not played with simple dialogs, but it looks to me like you need to use and dialog - I think simple dialogs are meant just for yes-no responses.
      > >
      > > I don't know if that's the problem, it's what I'd try first. But also, you've a typo in your success handler. And I'd try and take the javascript out of the body of what's going to be the dialog content: I don't think it matters but it feels like it might be a bit circular. Can you send it after the form has been sent?
      > >
      > > Matt
      > >
      > >
      > > --- In ydn-javascript@yahoogroups.com, "lemoserges" <lemoserges@> wrote:
      > > >
      > > > Hello all,
      > > >
      > > > I have been scratching my head on the following for a couple of days now and thought it might be time to tap into you guys' knowledge. Any help would be very much appreciated.
      > > >
      > > > I am merely trying to use SimpleDialog to display a form in an overlay, then submit the form asynchronously. I get the following error from Firebug:
      > > >
      > > > Firebug's log limit has been reached. %S entries not shown. Preferences
      > > > [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: https://www.dev.mysite.net/includes/yui260/build/utilities/utilities.js :: anonymous :: line 15" data: no]
      > > > [Break on this error] var D=this.__yui_events[A];if(D){D.subsc...=true;}else{this._has_http_headers=true;
      > > >
      > > >
      > > > Here is my code (sorry for the mess, the form is dynamically generated):
      > > >
      > > > <div id="survey_overlay" style="background-color:#FFFFFF; padding-left:inherit" align="left">
      > > > <div id="inner_content"><p>
      > > > <font color="DC143C">Please take a moment to answer a quick survey question!</font></p>
      > > >
      > > > <script type="text/javascript">
      > > > function showSurvey() {
      > > >
      > > > var Event = YAHOO.util.Event,
      > > > Dom = YAHOO.util.Dom;
      > > > Event.onDOMReady(function () {
      > > > // Define various event handlers for Dialog
      > > > var handleSubmit = function() {
      > > > this.submit();
      > > > };
      > > >
      > > > // Define events for successful survey
      > > > var handleSuccess = function(o) {
      > > > alet("Thank you");
      > > > };
      > > > var handleFailure = function(o) {
      > > > alert("Submission failed");
      > > > };
      > > >
      > > > var oPanel3 = new YAHOO.widget.SimpleDialog("survey_overlay", { modal: true,
      > > > visible: true,
      > > > fixedcenter: true,
      > > > constraintoviewport: true,
      > > > width: "400px",
      > > > buttons: [ { text:"Send Feedback", handler:handleSubmit, isDefault:true }],
      > > > postmethod: "async"
      > > > });
      > > > // Wire up the success and failure handlers
      > > > //oPanel3.callback = { success: handleSuccess, failure: handleFailure }; oPanel3.setHeader("Quick survey");
      > > > oPanel3.render(document.body);
      > > > });
      > > >
      > > > }
      > > > </script>
      > > >
      > > >
      > > >
      > > > <form id="form__survey_form4" name="survey_form4" method="post" action="https://www.dev.mysite.net/survey/vchk_survey_record_answer.php?surveyor_id=2&question_id=4&user_type=Customers&user_id=944&form_name=survey_form4&form_type=checkbox&num_items=5">
      > > > <label>What are your favorite colors?</label><br />
      > > > <input type="checkbox" name="survey_form4_checkbox_0" value="item0" /> Red<br />
      > > > <input type="checkbox" name="survey_form4_checkbox_1" value="item1" /> Blue<br />
      > > > <input type="checkbox" name="survey_form4_checkbox_2" value="item2" /> Green<br />
      > > > <input type="checkbox" name="survey_form4_checkbox_3" value="item3" /> Orange<br />
      > > > <input type="checkbox" name="survey_form4_checkbox_4" value="item4" /> Yellow<br /><br />
      > > > <input type="hidden" id="used_for_id_id" value="" name="used_for_id_name" />
      > > > </form>
      > > > </div><script type="text/javascript">showSurvey();</script></div>
      > > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.