【问题标题】:How to open Foundation Reveal Modal with hash (#)如何使用哈希 (#) 打开 Foundation Reveal Modal
【发布时间】:2013-10-31 14:40:30
【问题描述】:

如果可能的话,谁能指出我正确的方向。

我想向用户发送一封电子邮件,其中包含指向特定页面的链接。我在该页面上有模态,我希望根据 url 使用特定的模态打开页面。 示例:

domain.com/story/#story1

以 OPEN 显示模式打开页面,ID #story1

如果有人能提供帮助,我将不胜感激。

我在通过以下方式导航到页面时设法打开了模式窗口

("#Modal8").foundation('reveal', 'open');

有人建议我使用

<script>
    var hash = window.location.hash;

    if (hash === "#story8") {
        $('#Modal8').reveal({ 
            animation: 'fadeAndPop',                 //fade, fadeAndPop, none
            animationspeed: 300,                    //how fast animtions are
            closeonbackgroundclick: true,           //if you click background will modal close?
            dismissmodalclass: 'close-reveal-modal' //element that will close an open modal
        }); //You can use same modal or different modal to show success message
    } 
</script>

我试过没有成功。

【问题讨论】:

  • 什么是ef('#Modal8')

标签: jquery zurb-foundation reveal.js


【解决方案1】:

我在我的项目中使用 Expressionengine,所以我想出了一个简单的解决方案。也许它会帮助某人。我在页面上有 8 个模态,我有 8 个条件。我想你可以在频道中使用条件。 :)

{if last_segment == 'Modal8'}  //Modal8 can be changed to any url: latestnews or smth.
$("#Modal8").foundation('reveal', 'open'); 
</script>
{/if}

【讨论】:

    【解决方案2】:
    if (window.location.hash){
        $(document).ready(function () {
          let $blockHash = $(window.location.hash);
          //console.log($blockHash);
          if (($blockHash.length > 0) && ($blockHash.hasClass('reveal'))){
            $blockHash.foundation('open');//foundation 6
          }
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 2015-03-26
      • 2013-08-30
      • 1970-01-01
      相关资源
      最近更新 更多