Matt Elhotiby
Matt Elhotiby

Reputation: 44066

why does IE need for me to click twice

I have this jQuery

    $('.billing_info').click(function(e){
        e.preventDefault();
        if(($('.shipping_selection').length) > 0){
            if ($('.shipping_selection:checked').length == 0){
                $('.hide_error').show();
                $("html, body").animate({ scrollTop: $(".hide_error").offset().top }, "slow");
                $(".hide_error").effect("highlight", {}, 4000);
                return false;
            }else{
                $('.billing_info').unbind("click");
                $('.billing_info').click();
            }   
        }else{
            $('.billing_info').unbind("click");
            $('.billing_info').click();
        }
    });

which works awesome in all browsers except in IE. I'm using IE8 and the user needs to click the button twice for the button to accept the click event even if there is one radio button $('.shipping_selection') clicked

Upvotes: 2

Views: 3566

Answers (1)

Brandon J. Boone
Brandon J. Boone

Reputation: 16472

Perhaps a bit of refactoring would help. Only prevent default when you need to, otherwise let the function pass through to the default submit event.

$('.billing_info').click(function(e){
    if(($('.shipping_selection').length) > 0 && $('.shipping_selection:checked').length == 0){
            e.preventDefault();
            $('.hide_error').show();
            $("html, body").animate({ scrollTop: $(".hide_error").offset().top }, "slow");
            $(".hide_error").effect("highlight", {}, 4000);
            return false;
    }
});

Upvotes: 1

Related Questions