Object doesn't support property or method but then kinda works...

71 views
Skip to first unread message

Phil Petree

unread,
Jan 15, 2013, 12:43:23 PM1/15/13
to prototype-s...@googlegroups.com
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
    }
})

greg

unread,
Jan 16, 2013, 8:57:08 PM1/16/13
to prototype-s...@googlegroups.com
Off the top of my head, I think the target of your form should be the id of the iframe.

Phil Petree

unread,
Jan 17, 2013, 8:03:16 PM1/17/13
to prototype-s...@googlegroups.com
Hi Greg!
 
Thanks for looking at this...
 
Turns out that if I remove the submit handler from the wizard class and stop trapping the submit button it works just fine...
 
Not sure why this oddity is but it is and it works...
 
P~

On Wed, Jan 16, 2013 at 8:57 PM, greg <in...@wildanimaltracks.com> wrote:
Off the top of my head, I think the target of your form should be the id of the iframe.


--
You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group.
To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/sJgH4TRvAu8J.
To post to this group, send email to prototype-s...@googlegroups.com.
To unsubscribe from this group, send email to prototype-scripta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply all
Reply to author
Forward
0 new messages