2016-03-03 34 views
0

我想創建一個模式揭示,打開頁面加載與Zurb基金會6.我還想爲瀏覽器存儲一個cookie,以便如果用戶關閉顯示它不會再打擾他們7天。基金會6揭示在頁面加載與餅乾不工作

我使用的cookie jQuery插件發現here

這裏是我的html:

<div class="reveal" id="exampleModal1" data-reveal> 
    <h1>Awesome. I Have It.</h1> 
    <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> 
    <button class="close-button" data-close aria-label="Close modal" type="button"> 
    <span aria-hidden="true">&times;</span> 
    </button> 
</div> 

正如你可以看到我沒有數據,開放式的元素,因爲我想的模式來一旦頁面加載打開。

這裏是我的jQuery:

jQuery(document).ready(function($) { 
if ($.cookie('modal_shown') === null) { 
     $.cookie('modal_shown', 'yes', { expires: 7, path: '/' }); 
     $("#exampleModal1").foundation('reveal', 'open'); 
    } 
}); 

jQuery的是,在不衝突模式。

但是,這似乎並沒有工作。我沒有通過我的開發者控制檯在Chrome中發現任何錯誤。我真的很感謝幫助。

回答

0

我已經發布瞭解決方案,任何人都需要它。

原來,在基礎6,你不需要使用既揭示和開放的方法,只需打開。

jQuery(document).ready(function($) { 
    if($.cookie('showed_modal') != "true") { 
    $("#exampleModal1").foundation("open"); 
    $.cookie('showed_modal', 'true', { expires: 7, path: '/'}); 
    } 
});