2013-09-28 60 views
2

我將基金會4添加到我的流星網絡。我用這個包Meteorjs基金會模態事件凍結瀏覽器

https://atmosphere.meteor.com/package/foundation 

我遵循的基礎上主頁Foundation 4

<div id="myModal" class="reveal-modal"> 
    <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 href="#" data-reveal-id="myModal" class="open radius button">Example Modal…</a> 

模態正確地打開鏈接,但是當我嘗試關閉瀏覽器被凍結的模式。我測試了將其他事件添加到模式,例如只是執行控制檯日誌的鏈接,並且也凍結了。看起來我不能使用模態內的事件...關於如何關閉模態並添加事件的任何想法?

thx

回答

1

你試過把模態放在模板中嗎?

<head> 
    <title>foundation</title> 
</head> 

<body> 
    {{> foundation}} 
</body> 

<template name="foundation"> 
    <h1>Hello World!</h1> 

    <div id="myModal" class="reveal-modal"> 
     <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 href="#" data-reveal-id="myModal" class="open radius button">Example Modal…</a> 
</template> 

這樣的關閉按鈕似乎正在爲我工​​作時,這樣做。

如果你需要監聽的模式事件,你可以只指定一個或在客戶端代碼多個事件處理程序:

// foundation.js - foundation is the name of my meteor project 
// so this is the default file added to my project 
if (Meteor.isClient) { 

    Template.foundation.events({ 
    "click h2": function(e) { 
     console.log("modal h2 clicked"); 
    } 
    }); 

    Template.foundation.rendered = function() { 
    // you can bind custom events here if you need to 
    } 
} 


if (Meteor.isServer) { 
    Meteor.startup(function() { 
    // code to run on server at startup 
    }); 
} 
+0

曾爲THX很多 – Nonyck

+0

詞警告,如果你的」 .reveal模態「不是直接插入到標記下,那麼Foundation將[製作副本](https://github.com/zurb/foundation/blob/master/js/foundation/foundation.reveal.js#L254)在顯示之前是指Meteor事件不會被綁定到它。因此,請確保您的模態元素被定義爲您的標記的第一個孩子以避免問題。 –