Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foundation 5.1 Off-canvas Not Working on iOS Safari (Simulator)

The code below works just fine on a desktop browser (Safari and Firefox) but the menu button does not work with Mobile Safari (when I click nothing happens and I was expecting the menu to show).

I have an old simulator (iOS 5) but Foundation's example code works from their page on the same mobile browser so I am not sure what I am doing wrong. For example, the advanced section in this link works just fine on the same mobile browser: http://foundation.zurb.com/docs/components/offcanvas.html and my code is pretty much a copy of theirs.

JS Fiddle link here: http://jsfiddle.net/rGyKv/

Update: Changed the title to off-canvas as opposed to Topbar.

<html lang="en" class="no-js">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width" name="viewport">

    <link href="/static/css/foundation.min.css" rel="stylesheet">

    <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
    <script src="http://localhost:8080/static/js/foundation.min.js"></script>

    <meta class="foundation-data-attribute-namespace">
    <meta class="foundation-mq-xxlarge">
    <meta class="foundation-mq-xlarge">
    <meta class="foundation-mq-large">
    <meta class="foundation-mq-medium">
    <meta class="foundation-mq-small">

    <script> $(document).ready(function() {$(document).foundation();});</script>

    <meta class="foundation-mq-topbar">

</head>

<body>
<div class="row">
    <div class="small-12 columns end">
        <div class="off-canvas-wrap docs-wrap">
            <div class="inner-wrap">
                <nav class="tab-bar">
                    <section class="left-small">
                        <a class="left-off-canvas-toggle menu-icon"> 
                                             <span> </span> </a>
                    </section>
                    <section class="middle tab-bar-section">
                        <h1 class="title">Title</h1>
                    </section>
                </nav>
                <aside class="left-off-canvas-menu">
                    <ul class="off-canvas-list">
                        <li> <label> Welcome </label> </li>
                        <li> <a href="#">Home</a> </li>
                        <li> <a href="#"> Logout </a> </li>
                    </ul>
                </aside>
                <section class="main-section">
                    <div class="row">
                        <div class="small-12 columns">
                            <br>
                            <h4 class="">Header</h4>
                            <p> CONTENT GOES HERE</p>
                        </div>
                    </div>
                </section>
                <a class="exit-off-canvas">
                </a>
            </div>
        </div>
    </div>
</div>



</body>
</html>
like image 606
Ecognium Avatar asked Feb 09 '14 05:02

Ecognium


2 Answers

Add the href to this line:

<a class="left-off-canvas-toggle" href="#" >

This will address the issue for IOS

like image 83
Rafi Avatar answered Oct 21 '22 17:10

Rafi


I encountered the same problem and after some searching I've found a hack by user vietqhoang on Github.

Using the following code to initialise foundation somehow fixed the non-clickable buttons on iOS for me.

$(document).ready(function() {
    $(document).foundation();

    // Hack to get off-canvas .menu-icon to fire on iOS
    $('.menu-icon').click(function(){ false });
});
like image 30
Willem Liu Avatar answered Oct 21 '22 17:10

Willem Liu