Skip to content Skip to sidebar Skip to footer

Javascript/jquery On Click, Confirm Fires Twice

Problem solved itself... FYI: Apparently that was Mac OS or Chromium engine bug as after last system and browser updates problem disappeared as suddenly as it appeared before. It l

Solution 1:

I think you should use .one

$(document).one('click', '.myBtn', function () {

Description: .one() Attach a handler to an event for the elements. The handler is executed at most once per element per event type.

Solution 2:

Try to clear your cache in chrome setting as well as history of the file And then close your browser. Then try again.

I use this code similar like you and it works!

<script>//$(document).ready(function () {
        $(document).on('click', '.myBtn', function () {
            console.log('Let us check...');
            var confirmation = confirm('Are you sure you want ' + $(this).data('field') + '?');
            console.log(confirmation);
        });
   // });</script>

It fires one! That's chrome. I'm not sure it is a bug. It's perhaps the way chrome store it. But I haven't try in Opera at Mac (since, I have no mac with me)

Post a Comment for "Javascript/jquery On Click, Confirm Fires Twice"