vojtech-dobes / nette.ajax.js

Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
https://componette.org/vojtech-dobes/nette.ajax.js/
MIT License
149 stars 85 forks source link

IE8 error when submitting form: Object doesn't support this action #119

Closed janedbal closed 7 years ago

janedbal commented 9 years ago

Error is raised when you submit ajaxifized form for the second time (form was re-rendered by snippet replacement). Problem is on this line as it was previously reported on nette forum.

How to reproduce:

$form = new \Nette\Application\UI\Form();
$form->addSubmit('send');
$form->getElementPrototype()->addClass('ajax');
$form->onSuccess[] = function ($form) {
    $this->redrawControl('content');
};
janedbal commented 9 years ago

Oh, now I see that the original problem is #75 and people were reporting the same thing as I'm in comments of commit b96243f35b58c880dd1fad2778395a08a8193c69. The proposed solution works, may I send PR?

Working fix:

if (validate.form && analyze.form && !((analyze.isSubmit || analyze.isImage) && analyze.el.attr('formnovalidate') !== undefined)) {
    var ie = this.ie();
    if ((typeof ie === 'undefined' || ie >= 9)) {
        if (analyze.form.get(0).onsubmit && analyze.form.get(0).onsubmit(e) === false) {
            e.stopImmediatePropagation();
            e.preventDefault();
            return false;
        }
    }
}
vojtech-dobes commented 7 years ago

I think this has been fixed long time ago.