MarcelFrehe
MarcelFrehe

Reputation: 143

Internet Explorer lags on assignment of a function to "onfocusout" Event

My HTML form is performing an action (adding a new Line to the form to be able to enter another phone-number) when the user left the current input field.

This code results in a massive Lag when executed with IE:

    $("#createOrUpdateContactPersonPhoneNumber0").on('focusout', function() {
       addAnotherRow();
    });

function addAnotherRow() {

 $("#phoneNumberTable tr:last-child").before('<tr><td><select style="width: 100px;" id="createOrUpdateContactPersonPhoneType' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><select id="createOrUpdateContactPersonPhoneCountry' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><input style="height: 21px;" type="text" id="createOrUpdateContactPersonPhoneNumber' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></td><td><input style="height: 21px; width: 100px;" type="text" id="createOrUpdateContactPersonPhoneExtension' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></td><td><select id="createOrUpdateContactPersonPhonePurpose' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"></select></td><td><center><input type="radio" name="createOrUpdateContactPersonPhonePrimary" id="createOrUpdateContactPersonPhonePrimary' + $("#phoneNumberTable tr:not(:first-child):not(:last-child)").length + '"/></center></td><td></td></tr>');

};

When adding the code of the function "addAnotherRow()" directly into the .on('focusout') event there is no Lag.

Upvotes: 0

Views: 28

Answers (1)

Sven Tschui
Sven Tschui

Reputation: 1435

Use onBlur instead of onFocusOut. Note that onBlur does not bubble.

Upvotes: 1

Related Questions