PhotoSwipe icon indicating copy to clipboard operation
PhotoSwipe copied to clipboard

previous, next and close buttons submit form

Open marten-seemann opened this issue 11 years ago • 5 comments

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.

marten-seemann avatar Dec 11 '14 16:12 marten-seemann

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.

dimsemenov avatar Dec 11 '14 20:12 dimsemenov

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

marten-seemann avatar Dec 11 '14 20:12 marten-seemann

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

dimsemenov avatar Dec 11 '14 20:12 dimsemenov

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.

knicklabs avatar Dec 20 '15 05:12 knicklabs

I just tried PhotoSwipe and have the same issue. Any update since 2015 ?

nicolasigot avatar May 06 '21 16:05 nicolasigot