Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Click event not firing when clicking on an element's padding

Has anyone ever experienced a similar thing? When I click on the middle area of an li element, the click event fires, but when clicking on the padded area towards its edge the event doesn't fire.

I'm binding to click on the element.

Super stumped.

like image 791
Ian Storm Taylor Avatar asked Feb 22 '12 15:02

Ian Storm Taylor


2 Answers

I also saw this happening, but only on iOS. Wrapping with a div didn't work either. After some research I discovered that the YUI delegate listener was not firing on that node's padding (though it did everywhere else on the node). Ultimately, I fixed it by removing that node from the delegate listener entirely and adding a traditional click event listener for just that node. After that, it worked fine!

Not sure if this will help your situation or not.

like image 143
jeffers102 Avatar answered Sep 20 '22 16:09

jeffers102


This is no solution, just a workaround, but wrap the whole content of an li in a wrapper div. Apply your padding to the div and not the li. This solved my issue, but this still seems like a very weird bug to me.

like image 40
gnclmorais Avatar answered Sep 21 '22 16:09

gnclmorais