user263444
user263444

Reputation: 61

Jquery live - focusin fires multiple times

I am using JQuery 1.4.1. I have HTML input elements which created dynamically. I have assigned "focusin" event all input elements. While loading page, it is triggers only once while focusing each input element.

Problem is, When I minimize and maximize the page, focus event is fired multiple times. Finally it show "Stack overflow at line 0".

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

    })

What could be causing this problem?

Upvotes: 6

Views: 4601

Answers (1)

kenfai
kenfai

Reputation: 393

Don't worry. It only happens when you call alert(). But I don't really understand why clicking the OK button on the alert box will trigger the event multiple times.

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

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

Same as focus, click, and other events.

Upvotes: 16

Related Questions