2

我将基础 4 添加到我的流星网络。我用这个包

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…&lt;/a>

模态正确打开,但是当我尝试关闭模态时,浏览器被冻结。我测试了将其他事件添加到模式中,例如仅执行控制台日志的链接,并且也被冻结。看起来我不能在模式中使用事件......关于如何关闭模式并向其中添加事件的任何想法?

谢谢

4

1 回答 1

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…&lt;/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
  });
} 
于 2013-09-28T15:14:22.670 回答