Jquery live - focus constantly works

I am using jQuery 1.4.1. I have HTML input elements that are created dynamically. I assigned a focusin event to all input elements. When a page loads, it starts only once when focusing each input element.

The problem is that when I minimize and maximize the page, the focus event fires several times. Finally, it shows "Stack Overflow on Line 0".

$('input').live("focusin",function(objectRef) { alert("focusin event"); }) 

What could be causing this problem?

+4
source share
1 answer

Do not worry. This only happens when alert() called. But I do not understand why clicking the "OK" button in the warning window triggers an event several times.

Try this instead, and it will only fire once, as expected.

 $('input').live("focusin",function(objectRef) { //alert("focusin event"); $("#some_div").append('focus!'); }) 

Same as focus , click and other events.

+12
source

Source: https://habr.com/ru/post/1299938/


All Articles