Zurb Foundation 6 Reveal doesn't work

我的梦境 提交于 2019-12-18 15:28:45

问题


I've downloaded the new Zurb Foundation 6 complete package (Foundation for Sites). The archived file contains the following files and folders:

[css] > app.css, foundation.css, foundation.min.css
[img] > [empty folder]
[js]  >
  app.js
  foundation.js
  foundation.min.js
  vendor > jquery.min.js, what-input.min.js

I included the JS file in the footer and the CSS at the header:

<!-- foundation library and initialization -->
<script src="/Foundation/js/foundation.min.js"></script>
<script>
  $(document).foundation();
</script>

Error in Chrome

I try to use REVEAL component (it worked in Foundation 5), but this time it throws me an error:

Uncaught ReferenceError: We're sorry, 'reveal' is not an available method for i.

I've looked inside the Foundation.min.js and it has REVEAL in it. I download the complete package, so it should work, but it doesn't.

The JS code that should trigger the modal:

$('#submit-modal').foundation('reveal', 'open');

UPDATE 1: Tried on a fresh page:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="/Foundation/css/foundation.min.css" rel="stylesheet" />
</head>
<body>
    <div class="row">this is the body of the page</div>
     <div id="popup-modal" class="reveal-modal full" data-reveal aria-labelledby="pop-up-modal-title" aria-hidden="true" role="dialog">
         test
     </div>

<script src="/Foundation/js/vendor/jquery.min.js"></script>

<!-- foundation library and initalization -->
<script src="/Foundation/js/vendor/what-input.min.js"></script>
<script src="/Foundation/js/foundation.js"></script>

<script>
    $(document).foundation();
</script>

</body>
</html>

The text of the popup appeared on the page, it's even not hidden by default, and I get an error: Uncaught ReferenceError: We're sorry, 'Reveal' is not an available method for Reveal when trying to run the command:

$('#popup-modal').foundation('reveal', 'open');

From the console.

Foundation 6 is a fresh release, and I;ve might missed something. I upgraded to Foundation 6 from Foundation 5. Foundation 5 Reveal worked ok, but after changing to the new Foundation 6 some components start not working out.

I checked the Documentation and the initialization and classes are the same.


回答1:


Try with

var popup = new Foundation.Reveal($('#popup-modal'));

and then:

popup.open();

I am not sure if $('#popup-modal').foundation('reveal', 'open'); works in Foundation 6




回答2:


Chris from ZURB here. There's a couple of ways you can invoke methods on plugins, see: http://foundation.zurb.com/sites/docs/javascript.html#programmatic-use

The easy way now is $('#exampleModal').foundation('open')




回答3:


Both options provided by Juliancwirko & EddieDean are working. But there's a difference.

If you are using "new Foundation" approach and you also have data-options set like: data-options="closeOnEsc: false; closeOnClick: false;" they won't have any effect.

But if you are using foundation('open') they will work.



来源:https://stackoverflow.com/questions/33855505/zurb-foundation-6-reveal-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!