Riot: Any click event inside a form fires a form submission event

Created on 29 Nov 2016  路  3Comments  路  Source: riot/riot

Help us to manage our issues by answering the following:

  1. Describe your issue:

Any button inside of a form with a click event will cause a page reload, I'm not sure if this is desirable.
I think it would be more appropriate for the button to have a type="submit" attribute for this to occur

  1. Can you reproduce the issue?
<form>
<button onclick={click}>click</button>
</form>

<script>
  click () { console.log('click'); }
</script>
  1. On which browser/OS does the issue appear?

Chrome

  1. Which version of Riot does it affect?

3.0.0 and 3.0.1

  1. How would you tag this issue?

    • [ x ] Question
    • [ ] Bug
    • [ x ] Discussion
    • [ ] Feature request
    • [ ] Tip
    • [ x ] Enhancement
    • [ ] Performance
answered question

Most helpful comment

You can put type="button", because button default type here is submit

All 3 comments

You can put type="button", because button default type here is submit

@rongxike thank you for your clear answer!
@shouston3 auto pteventDefault feature has been deprecated in Riot 3.0. Pls check our release note, too.
http://riotjs.com/release-notes/#november-22-2016

Makes sense, thanks for the fast response

Was this page helpful?
0 / 5 - 0 ratings