IE9 click event handler firing /called twice, OK in compatibility mode.
IE9 click event handler firing /called twice, OK in compatibility mode and solution (jQuery)
I just noticed some strange behaviour in IE9.
Code fragment:
function bindCtrl(){ $('#smallccontrol a').bind('click', function(e){ e.preventDefault(); if(smallCEnabled){ removeSmallC(); }else{ enableSmallC(); } smallCEnabled = !smallCEnabled; return false; }); }
It worked in all modern browsers except IE9. When I clicked the anchor matching '#smallccontrol a' the function was called twice.
The site was using jQuery 1.3.2 which admittedly is a little old.
Solution:
I used live instead of bind which fixed the problem: So the updated code :
function bindCtrl(){ $('#smallccontrol a').live('click', function(e){ e.preventDefault(); if(smallCEnabled){ removeSmallC(); }else{ enableSmallC(); } smallCEnabled = !smallCEnabled; return false; }); }








