This gist demonstrates that you need a lot of special handlers for form submission...
Last active
December 21, 2015 04:29
-
-
Save ericanderson/6249871 to your computer and use it in GitHub Desktop.
Many ways to submit a form...
This file contains 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
$ -> | |
$('#form2').submit (e) -> | |
alert('on submit') | |
e.preventDefault() |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | |
<title></title> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/coffee-script/1.6.3/coffee-script.min.js"></script> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/coffeescript" src="code.coffee"></script> | |
</head> | |
<body> | |
<h1>No event handlers</h1> | |
<p>Try pressing enter in this textbox...</p> | |
<form id="form1"> | |
<input type="text" name="foo"> | |
<button>Submit</button> | |
</form> | |
<h1>Form w/ submit handler + preventDefault()</h1> | |
<form id="form2"> | |
<input type="text" name="foo"> | |
<button>Submit</button> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment