Why Doesn't This JQuery Code Work In IE?
The following code is used so when clicking 'enter' when focused in an input field within a form, it disables the standard submit button functionality. Rather the javascript build
Solution 1:
What happens if you try using the normal DOM submit method instead of jQuery's?
// instead of:
// $form.submit();
// try this:
$form[0].submit();
ie gives me a javascript error: 0 is null or not an object..
Ok, that would suggest that your jQuery object is empty. It might be the appendTo which is doing strange things... try this:
$form = $form.appendTo("body");
$form.submit();
and if that doesn't work, put in these debugging lines:
alert($form.length);
$form.appendTo("body");
alert($form.length);
$form.submit();
Ok, I've got it now:
It's the line where you generate the form which is causing the problem. Change it to this:
var $form = $("<form></form>").attr({"action" : url_string, "method" : "POST"});
What you had should have worked, so that might be a bug in jQuery, I'm not sure.
Solution 2:
The IE DOM is different and capturing the event is different than FF or Chrome.
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if(key == 13)
do a thing
Post a Comment for "Why Doesn't This JQuery Code Work In IE?"