Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
Created January 27, 2012 17:33
Show Gist options
  • Save i-like-robots/1689926 to your computer and use it in GitHub Desktop.
Save i-like-robots/1689926 to your computer and use it in GitHub Desktop.
IE6 and 7 button element submit behaviour shim
/**
* IE 6 and 7 button[type=submit] shim
*
* @description Correct behaviour for button[type=submit] elements in IE 6 (all are submitted) and 7 (value is inner text). The
* following is only necessary if you must use button[type=submit] elements, otherwise stick to input[type=submit][class=button]
*/
$(function()
{
$('button[type=submit]').on('click', function()
{
var $this = $(this);
$this.after('<input type="hidden" name="' + $this.attr('name') + '" value="' + $this.val() + '" />');
});
$('form').on('submit', function(e)
{
e.preventDefault();
$('button').attr('disabled', 'disabled');
this.submit();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment