I'm working on submitting a form using a hidden iFrame target...  inside
the wizzard class the f.submit(); throws the method error but as soon as
you step over it in the debugger it calls the forms processor and the form
data is processed.  If you ignore the error in normal browser mode I get an
popup from the oncomplete that basically says there's a syntax error in
processing the return json from the target but the catch gets thrown and
the content displayed is from the main windown and not the target iframe.

I'm apparently really lost in this..

HTML:
<div style='display: none'>
  <iframe id='wizzardTarget' name='wizzardTarget' src=''>
  </iframe>
</div>

<form name='kitForm' id='newkitOne' action='newkit1_ajax.php' method='post'
target='uploadTarget' enctype="multipart/form-data">
<!-- blah blah -->
<input type='submit' id='submit' value='Save >>'
onclick='validate_newkitOne();'>
</form>

Javascript:
function WizMaker(szForm, szTarget)
{
  var wizard = new Wizzard(szForm, szTarget);
  alert(szForm +" " +szTarget);  // this verifies that the form name and
target are indeed correct.
}

var Wizzard = Class.create({
    initialize: function(form, target) {
        this.form = form;
        this.target = target;  //iframe

        $(this.form).observe('submit', this.upload.bind(this));
        $(this.target).observe('load', this.complete.bind(this));
    },

    upload: function() {
        // process form...
        var f = $(this.form);
        f.submit();   // this line generates the object/method error but
then calls the forms processor.
    },

    complete: function() {
        var json;

        try
        {
          json =
frames[this.target].document.getElementsByTagName('body')[0].innerHTML.evalJSON();
        }
        catch(e)
        {
          // this alert shows the contents of the main window and not the
target iframe
          alert(
frames[this.target].document.getElementsByTagName('body')[0].innerHTML() );
          // this error message shows "syntax error"
          alert('PressPeek Error: Form not submitted because: ' +e);
          return;
        }
        // snip... what's left is just updating some internal variables....
none of which ever happens
    }
})

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to