2
Vote

Button value not posted correctly on IE7 with unobtrusive.ajax

description

Having a button

<button type="submit" name="action" class="next" value="next">Submit</button>

in IE8+ once the above button is used the Form["action"] will have the value "next". On IE7 the value will be "Submit". This is because the JavaScript .value property on IE7 will return the text not the actual value.

This can be fixed by changing line 144 in the jquery.unobtrusive-ajax.js from

$(form).data(data_click, name ? [{ name: name, value: evt.target.value }] : []);

to

$(form).data(data_click, name ? [{ name: name, value: $(evt.target).val() }] : []);

Using jQuery returns the correct value.

comments