This is kinda tough to explain, so bear with me.
On mobile devices, I load a script named "mobile.js" in the header. This script has functions to detect a swipe and a taphold (which I believe were both recommended on here), and then I also include a function to hide a specific element when the user focuses on an input, textarea, or contenteditable:
- $(function() {
- if ($('#local_banner').css('display') != 'none') {
- $('input, textarea, [contenteditable]')
- .on('focus', function() {
- console.log('a');
- $('#local_banner').hide();
- })
- .on('blur', function() {
- console.log('b');
- $('#local_banner').show();
- });
- }
- });
I load the contenteditable script on the page in a separate Ajax, mainly because it's a little hefty in size, and since it loads near the bottom of the page I just force it to be the last thing to load.
Input tags and textareas load on the page normally, though.
What I've discovered is that when I click on an input element, #local_element hides and shows as expected. But clicking on the contenteditable doesn't do anything, and it doesn't show up in the console log that the focus or blur are triggered at all.
But when I moved the above script to the bottom of the Ajax, though, it DID work.
To add to the confusion, I have another script in the header (just below mobile.js) that runs on all devices, and it includes variable names, the Ajax function, etc. This script DOES appear to be running within the Ajax!
Can you guys suggest a reason why this one script isn't running as expected?