cotton123236 / zoomist

Zoomist is a library built with TypeScript that allows you to create zoom elements on website quickly and easily.
https://zoomist.vercel.app/
MIT License
104 stars 23 forks source link

Zoomer buttons cause a form submition #39

Closed pepkin88 closed 3 months ago

pepkin88 commented 9 months ago

Because the zoomer buttons don't have the type attribute set on them, it gets the default value, which is submit. That's why when Zoomist gets instantiated inside a form, clicking on those button will cause a form submission.

The solution to this would be setting the type attribute to "button" upon the element creation.

adriallongarriu commented 7 months ago

I was having the same problem issue. For now I used the following code to fix it temporarily:

const zoomist = new Zoomist('.zoomist-container', {
      on: {
          ready(zoomist, scale) {
            $('.zoomist-zoomer-button').attr("type", "button");
          }
        }
  })

After ready and the buttons are created add the type "button"

cotton123236 commented 3 months ago

Hey @pepkin88 @adriallongarriu ,

The buttons are set the type attribute to button by default now (v2.0.12). Thanks for waiting and liking this library!