Reputation: 143
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
Reputation: 1435
Use onBlur instead of onFocusOut. Note that onBlur does not bubble.
Upvotes: 1