react icon indicating copy to clipboard operation
react copied to clipboard

onSubmit without submit input not working

Open teosz opened this issue 12 years ago • 5 comments

I can't handle native submit with onSubmit ( https://www.youtube.com/watch?v=U2a3V2XcIcY&feature=youtu.be )


React v0.12.0

teosz avatar Nov 03 '14 15:11 teosz

It's not very easy to follow what's actually going on there, would it be possible to create a repro?

syranide avatar Nov 03 '14 21:11 syranide

Going to close this out but if you can make a minimal repro case, please post it here and I'll reopen.

sophiebits avatar Nov 12 '14 10:11 sophiebits

<form ref="form" onSubmit={(e)=>{ 
// this event not fired if submit form on click button if button not in form 
}}></form>

<button onClick={e=>{ReactDOM.findDOMNode(this.refs.form).submit()}}>Submit form</button>

how do it?

borm avatar Jul 04 '16 10:07 borm

@bORm Ideally, browsers do not fire the onsubmit event when the form's submit() method is called (http://jsbin.com/coluxo/1/edit?html,js,console,output). You can move the onsubmit handler to a method in the component & call it.

selvagsz avatar Jul 04 '16 11:07 selvagsz

@selvagsz any idea how submit form from outside & fire onsubmit event?

borm avatar Jul 04 '16 13:07 borm