【问题标题】:using modals in meteor templates在流星模板中使用模态
【发布时间】:2015-02-08 01:31:34
【问题描述】:

我有 modal.html:

    <template name="modal">
      <div class="modal fade">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <h2 class="modal-title">Dialog</h2>
            </div>
            <div class="modal-body">
              <p>
                Dialogs are typically used to prompt users to make a specific decision
                as part of or before continuing with a task or process. They can be used
                to inform users about a specific issue, to confirm particularly important
                actions, or to explain significant ramifications of an action before
                allowing the user to proceed.
              </p>
            </div>
            <div class="modal-footer">
              <button class="btn btn-flat pull-left">More info...</button>
              <button class="btn btn-flat" data-dismiss="modal">Close</button>
              <button class="btn btn-flat btn-primary" data-dismiss="modal">Save</button>
            </div>
          </div>
        </div>
      </div>
    </template>

我有 transfer.html 和 transfer.js

<template name="transfer">
  <!-- Somewhere inside  template --> 
  <a href="#" class="btn small-btn btn-fab reminder-btn" id="lock-pay" data-toggle="tooltip" data-placement="right" title="foo"><i class="fa fa-lock"></i></a>
</template>

Template.transfer.events({
  'click #lock-pay': function(event) {
    event.preventDefault();
    $('#modal').modal('show');
  }
})

我尝试将模态模板与我的传输放在同一个文件中,但这也不起作用

【问题讨论】:

  • 我写了一个包,使它易于使用 bootstrap 3 模态。随时use itread the code

标签: javascript jquery twitter-bootstrap meteor


【解决方案1】:

我认为您忘记在 HTML 中的某处实际呈现模态模板,试试这个:

<template name="transfer">
  {{> modal}}
  <a href="#" class="btn small-btn btn-fab reminder-btn" id="lock-pay" data-toggle="tooltip" data-placement="right" title="foo"><i class="fa fa-lock"></i></a>
</template>

如果您想使用# 引用它,您需要为模态div 分配一个id:

<div id="modal" class="modal fade">
  ...
</div>

您应该使用data-toggledata-target 来打开一个模式,而不是自己管理点击事件。

<a href="#" data-toggle="modal" data-target="#modal"></a>

【讨论】:

  • 请添加您的模态代码以进一步诊断问题。
  • 谢谢!我可以有多个'data-toggle',即:data-toggle="tooltip modal"?
猜你喜欢
  • 2018-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-15
  • 2013-05-27
  • 2015-01-10
相关资源
最近更新 更多