Skip to content

Instantly share code, notes, and snippets.

@dgm
Created September 25, 2010 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgm/597180 to your computer and use it in GitHub Desktop.
Save dgm/597180 to your computer and use it in GitHub Desktop.
Funny form submit behaviour
<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