Photoswipe: previous, next and close buttons submit form

Created on 11 Dec 2014  路  4Comments  路  Source: dimsemenov/PhotoSwipe

When the _.pswp_ element is wrapped in a form, every click on the previous, the next and the close button submits this form.

I created a demo by adding a

  <form onsubmit="alert('submit')">

around the

  <div class="pswp">...</div>

Without having dug deeply into the PhotoSwipe code, I think it should not be necessary to execute the submit action here.

Most helpful comment

What is the rationale behind not adding type="button"? By default, the type is submit so this will always cause problems when using PhotoSwipe within forms. This seems like an unintended side effect to me that would warrant an issue.

All 4 comments

You may add type="button" to PhotoSwipe button elements. Or just don't put .pswp in form, you can add it dynamically anywhere, just before the initialisation.

Ok. Do you want me to send a pull request?

No. If the problem will come up often - I'll implement JS-based solution.

What is the rationale behind not adding type="button"? By default, the type is submit so this will always cause problems when using PhotoSwipe within forms. This seems like an unintended side effect to me that would warrant an issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoffreyT picture JoffreyT  路  5Comments

silentbugs picture silentbugs  路  5Comments

horst-n picture horst-n  路  4Comments

arnowelzel picture arnowelzel  路  5Comments

caztcha picture caztcha  路  5Comments