Created
September 25, 2010 19:25
-
-
Save dgm/597180 to your computer and use it in GitHub Desktop.
Funny form submit behaviour
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
<html> | |
<head> | |
<script src="jquery-1.4.2.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
// handle some keypresses to navigate in a grid style | |
$('.tabstop').live('keydown',function(e){ | |
switch(e.which) { | |
case 40: // down | |
e.preventDefault(); | |
$(this).nextAll().filter('.tabstop').first().focus(); | |
break; | |
case 38: // up | |
e.preventDefault(); | |
$(this).prevAll().filter('.tabstop').first().focus(); | |
break; | |
} | |
}); | |
$('form').live('submit', function (e) { | |
e.preventDefault(); | |
alert("live submit called"); | |
return false; | |
}); | |
$('form input').live("focusout",function(e){ | |
e.preventDefault(); | |
alert('focus lost'); | |
console.debug($(this).closest('form').data("events")); | |
$(this).closest('form').submit(); | |
}); | |
</script> | |
</head> | |
<body> | |
<form action="http://www.google.com" data-remote="true"> | |
<input name="foo" id="foo" type="text" class="tabstop" data-column="foo"><br> | |
<input name="bar" id="bar" type="text" class="tabstop" data-column="foo"> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment