Created
June 10, 2016 00:35
-
-
Save RyanHirsch/10d66a66a244ab30ebafd9b8e8ad8b3f to your computer and use it in GitHub Desktop.
I have this amazingly complicated form. When I hit enter when in the input field, it always triggers the first button, not the submit (unless submit is first) why?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form onSubmit={ evnt => { | |
| evnt.preventDefault(); | |
| console.log({ pendingUser }); | |
| handleSave(person.merge(getValues(pendingUser))); | |
| }} > | |
| <div className="form-group"> | |
| <label htmlFor="firstname">First Name</label> | |
| <input id="firstname" className="form-control" ref={ bindInput.bind(this, pendingUser, 'firstname') } defaultValue={ firstname } type="text" /> | |
| </div> | |
| <div className="form-group"> | |
| <label htmlFor="lastname">Last Name</label> | |
| <input id="lastname" className="form-control" ref={ bindInput.bind(this, pendingUser, 'lastname')} defaultValue={ lastname } type="text" /> | |
| </div> | |
| <div> | |
| <button onClick={ evnt => { | |
| evnt.preventDefault(); | |
| console.log('cancel clicked'); | |
| handleCancel(); | |
| }}>Cancel</button> | |
| <input type="submit" value="Save" /> | |
| { handleDelete && <button onClick={ evnt => { | |
| evnt.preventDefault(); | |
| handleDelete(person.get('id')); | |
| }}>Delete</button> } | |
| </div> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment