Skip to content

Instantly share code, notes, and snippets.

@Nowaker
Forked from kamranayub/iebuttonfix.js
Created March 1, 2012 13:00
Show Gist options
  • Save Nowaker/1949690 to your computer and use it in GitHub Desktop.
Save Nowaker/1949690 to your computer and use it in GitHub Desktop.
IE 7 and below <button> tag value on POST fix
$(document).ready(function() {
if ($.browser.msie && ($.browser.version === "7.0" || $.browser.version === "6.0")) {
var getButtonValue = function($button) {
var label = $button.text();
$button.text('');
var buttonValue = $button.val();
$button.text(label);
return buttonValue;
}
$("button[name][value]").live('click', function () {
var $button = $(this);
var name = $button.attr("name");
var value = getButtonValue($button);
$("<input type='hidden' />").attr("name", name).val(value).insertAfter($button);
$button.attr("name", "ie_" + name);
});
}
});
@mmichaa
Copy link

mmichaa commented Apr 23, 2013

very nice script! :) But since jQuery v1.7 you should use .on() instead of .live()

the call could look like: $(document).on("click", "button[name][value]", function () { ... });

LoL ... my name ist Nowak too ;)

P.S. $.browser was removed since jQuery v1.9 :(
P.S.S. try this if you are missing $.browser: http://stackoverflow.com/a/14545032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment