0

I have the following problem. I have a script, which creates an iframe inside a regular HTML page (with XHTML strict declaration) and inside this iframe a form is created to request a PDF. Problem is: The form-element is lacking the submit Method.

The whole script works in a non-strict environment. Does anyone of you have an idea how to fix this? (Switching to non-strict is not an option)

Available Libraries:

  • PrototypeJS 1.5
  • Ext JS 2.1

Iframe and form present in DOM:

Iframe and form present in DOM

Form does not seem to have submit method

Form does not seem to have a submit method

philgiese
  • 623
  • 1
  • 7
  • 17
  • 1
    All forms have a submit method, so you have to explain that a lot better, as in what exactly it is you're trying to do ? – adeneo Nov 19 '13 at 12:27
  • You see, that is exactly the problem. There is a form in the DOM, but it has _no_ submit method. That's the problem. – philgiese Nov 19 '13 at 12:31
  • 1
    Now explain that, how does a form not have a submit method, it's built into HTML and as far as I know it can't be removed. Do you mean there's no submit button, or that there's no action attribute etc? A form can always be submitted, that's the point! – adeneo Nov 19 '13 at 12:34
  • Are you trying to submit the form with javascript? – AfromanJ Nov 19 '13 at 12:36
  • I'm trying to submit the form via javascript. Right after the step in which is created. Which, by the way, works fine. I see it in the DOM and all attributes, inputs are just fine. But assuming the form DOM-object is stored in a variable called `form` then `form.submit` yields `undefined`. – philgiese Nov 19 '13 at 12:42

1 Answers1

0

If you are using JQuery you will need to do the following for dynamically created forms:

$(document).on('submit', 'form', function(e) {
    console.log('clicked');
    e.preventDefault();
});

Binding to the document lets you capture events on elements that don't yet exist.

AfromanJ
  • 3,922
  • 3
  • 17
  • 33