Note that there are some explanatory texts on larger screens.

plurals
  1. PONo response in IE9 using jQuery on()
    primarykey
    data
    text
    <p>I have the following jQuery (version 2.0.3) set up to toggle my nav dropdown on both touch devices and desktops:</p> <pre><code>$(document).ready(function() { console.log("Ready handler triggered"); $(document).on({ click : ToggleNav, touchstart : ToggleNav }, "#NavToggle"); }); </code></pre> <p>My <code>ToggleNav()</code> function:</p> <pre><code>ToggleNav = function(event) { console.log(event.type); $('ul#Navigation').slideToggle(200); event.preventDefault(); } </code></pre> <p>And the relevant HTML:</p> <pre><code>&lt;div id='NavToggle'&gt;Navigation&lt;/div&gt; &lt;ul id='Navigation'&gt; &lt;li&gt;&lt;a href='/' title='Home'&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='/page-1.php' title='Page 1'&gt;Page 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='/page-2.php' title='Page 2'&gt;Page 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='/page-3.php' title='Page 3'&gt;Page 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href='/page-4.php' title='Page 4'&gt;Page 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>This works on every browser I've tested so far (Mac, Windows, and Chrome for Android) <em>except</em> for <strong>IE9</strong>, both 32 and 64-bit versions.</p> <p>The funny thing is that if I open Developer Tools and refresh the page it will start working, and I can then close Developer Tools and it will continue working no matter how many times I refresh. That is, until I close and reopen the browser.</p> <p>The <code>event.type</code> is successfully logged to the console ("LOG: click"), but the slideToggle() is apparently not being triggered and no errors are being logged to the console.</p> <p>Has anyone come across this before, and knows the cause and/or a solution?</p> <p><strong>Update 1</strong>: I updated the <code>ToggleNav()</code> function to also alert the <code>event.type</code> since opening the console to view the log also made IE9 start working. IE9 will not even show the alert, so the ToggleNav() function isn't even being triggered to begin with.</p> <p><strong>Update 2</strong>: After a bit more testing, I think the problem lies with the original on() handler. When I changed the <code>console.log("Ready handler triggered");</code> line to be an <code>alert()</code> instead it started working in IE9.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload