3

I am trying to use zurb foundation 5 reveal modal. But it's not working and not open when I click on button. I am using this html code.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link type="text/css" rel="stylesheet" href="css/foundation.css" />
<link type="text/css" rel="stylesheet" href="css/normalize.css" />
<title>index</title>
</head>
<body>
<div id="myModal" class="reveal-modal" data-reveal>
  <h2>Awesome. I have it.</h2>
  <p class="lead">Your couch.  It is mine.</p>
  <p>Im a cool paragraph that lives inside of an even cooler modal. Wins</p>
  <a class="close-reveal-modal">&#215;</a> </div>
<a class="button" href="#" data-reveal-id="myModal">Click for a modal</a>

<script src="js/vendor/jquery.js"></script> 
<script src="js/foundation/foundation.js"></script> 
<script src="js/foundation/foundation.reveal.js"></script> 
<script type="text/javascript"> 
   $('#myModal').foundation();
</script>
</body>
</html>
Gaurav Ktwl
  • 31
  • 1
  • 2

4 Answers4

11

Change the last script tag to this:

<script type="text/javascript"> 
    $(document).foundation();
</script>
Troy Carlson
  • 2,965
  • 19
  • 26
0

You also forgot to add the modal trigger:

<a href="#" data-reveal-id="myModal">Click Me For A Modal</a>

See documentation here: http://foundation.zurb.com/docs/components/reveal.html

Nathaniel Flick
  • 2,902
  • 2
  • 22
  • 31
0

You may be running into this issue if you have called $(document).foundation(); twice on the same page.

pat o.
  • 140
  • 5
-1

Its works for me

<a href="#" data-reveal-id="myModal" id="dd">Click Me For A Modal</a>
<div id="myModal" class="reveal-modal"  data-options="close_on_background_click:false" data-reveal>
    <h2>Awesome. I have it.</h2>
<p class="lead">Your couch.  It is mine.</p>
<p>I'm a cool paragraph that lives inside of an even cooler modal. Wins!</p>
<a class="close-reveal-modal">&#215;</a>
</div>

in footer i used this snippet

<script>
jQuery(document).ready(function(){
     jQuery(document).foundation();
  jQuery('#dd').click(function(){
  jQuery('#myModal').foundation('reveal', 'open');
  });
  
  
  });
     
  </script>
Saran
  • 358
  • 4
  • 9