Created
February 5, 2014 13:50
-
-
Save sturobson/8823990 to your computer and use it in GitHub Desktop.
What's going on with my JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| So I've got this code | |
| var $tooltips = $('.tooltip__link'); | |
| $tooltips.on('click touchstart', function(){ | |
| var tooltip = $(this); | |
| tooltip.toggleClass('js-opened'); | |
| return false; | |
| }); | |
| $('body').on('click touchstart', function(){ | |
| $tooltips.removeClass('js-opened'); | |
| }); | |
| I'm using touchstart here as iOS doesn't seem to wanna work without it. | |
| unfortunately | |
| $('body').on('click touchstart', function(){ | |
| $tooltips.removeClass('js-opened'); | |
| }); | |
| when tapping it invokes the form elements underneath the tooltip that's showing | |
| doing this | |
| $('body').on('click touchstart', function(){ | |
| $tooltips.removeClass('js-opened'); | |
| return false; | |
| }); | |
| fixes this but it seems to hijack the page for any other click events. | |
| Any ideas ? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should also turn the main body event off when the tooltip isn't open to prevent the click-jacking: