Alex Rivera | Logout

jQuery: Single button click, click event firing two or more times

Asked 2010-01-24T18:23:35.647
30

I have HTML input and button elements. I use the buttons to submit forms, open secondary windows, etc. The problem is, a single click is turning into 2 (and sometimes many more) form submissions, or opening two additional browser windows. I've reproduced the problem in multiple web browsers. I've tried switching jQuery versions and that didn't change anything. What could be causing this sort of thing to happen?

Edit
Report

1 Answer

6

for me it was caused by

$(function() {
    $('.some-element').click(function() {
        //event that fires twice
    });

    //some exception-throwing code here
});

jQuery was calling the anonymous ready function twice(?!) because of the exception so the click function would be bound twice.

answered 2010-12-15T02:37:05.050

Your Answer