Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple forms in modal not submitting any longer #362

Closed
fpalluel opened this issue Jun 15, 2017 · 1 comment
Closed

Multiple forms in modal not submitting any longer #362

fpalluel opened this issue Jun 15, 2017 · 1 comment
Labels

Comments

@fpalluel
Copy link
Contributor

Hello,

I updated from alpha.12 to beta.1. Since this update, a modal which contains 2 forms and a submit button, does not submit any longer. It fails silently, not error is shown in the console.

I narrowed down the issue to this commit (Removed jQuery-dependency)

I'm currently debugging to see where exactly it fails, but perhaps you will find the issue at once ;-)

@fpalluel
Copy link
Contributor Author

Ok, it is caused by the use of querySelector, which returns only the first form in the modal body. Before the update, the JQuery find method was used, which returned all the forms.

Here is the quick fix, using querySelectorAll :

    submit() {
      let forms = this.get('modalElement').querySelectorAll('.modal-body form');
      if (forms) {
        // trigger submit event on body forms
        let event = document.createEvent('Events');
        event.initEvent('submit', true, true);
        forms.forEach( (form) => {
          form.dispatchEvent(event)
        });
      } else {
        // if we have no form, we send a submit action
        this.get('onSubmit')();
      }
    }

No time to put a nice pull request right now, but I can later if you want ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants