0

I have a navigation menu that shows and hides on mobile devices when an element is clicked. It works everywhere except in Firefox on Samsung Galaxy 3. Here's the HTML:

<nav id="nav" role="navigation">
  <ul>
    <li>Menu Item 1</li>
    <li>Menu Item 2</li>
  Etc . .
  </ul>
 </nav>
 <div id="nav-arrow">&#9660;</div>

The element with the click event attached is "nav-arrow". Here is the jQuery:

$("#nav-arrow").click(function() {
        if ($("#nav").is(":visible")) {
            $("#nav").slideUp(800, function() {
                $("#nav-arrow").html("&#9660;");
            }); 
        } else {
            $("#nav").slideDown(800, function() {
                $("#nav-arrow").html("&#9650;");
            });             
        }
    });

The container is has a property of display:none until the nav-arrow is clicked. Can anyone help me get this working on Mobile Firefox?

joakland
  • 145
  • 8
  • I'm really not sure if what you are trying to do is possible. It should be, but I'm not entirely convinced that jquery has the necessary foundation to be handling clicks on mobile. I think what you want to do is use jquery-mobile and it's vclick event. – Brandon Kindred Oct 02 '14 at 20:34
  • This is working on every mobile device and browser except for Firefox on Samsung Galaxy. – joakland Oct 02 '14 at 21:15
  • See what using .on('click', function ... will do instead of just .click – tbh__ Oct 03 '14 at 01:39
  • http://stackoverflow.com/questions/21776570/jquery-mobile-click-event-doesnt-work This I think is your problem? – tbh__ Oct 03 '14 at 01:40
  • 1
    Using .on('click', had the same results. I ended up solving this problem by downloading just the touch events from the jQuery Mobile Download Builder and switching the click function to .on('tap', function . . . etc. That was the cure. – joakland Oct 03 '14 at 01:59

1 Answers1

1

jQuery Mobile requires the "delegate" method:

$(document).delegate('#nav-arrow', 'click', function () {
    if ($("#nav").is(":visible"))
    {
        $("#nav").slideUp(800, function()
        {
            $("#nav-arrow").html("&#9660;");
        }); 
    }
    else
    {
        $("#nav").slideDown(800, function()
        {
            $("#nav-arrow").html("&#9650;");
        });
    }    
});
Tim Samoff
  • 94
  • 11