1

在我的 Rails 应用程序中,我使用的是 Twitter 引导程序。

之前,一切正常,但突然模态开始显示两次。我不知道发生了什么..我的代码如下所示。

设计/注册/new.html.erb

<%= link_to "Terms of Service", terms_in_modal_path, {:class => "show-terms", :remote => true}

pages_controller

def terms_in_modal
  respond_to do |format|
    format.js
  end
end

terms_in_modal.js.erb

$("#signup-modal").html('<%= escape_javascript render(:partial => "terms_in_modal") %>');
$('#show-terms').modal('show');

_terms_in_modal.html.erb

<div id="show-terms" class="modal hide fade in">
...
</div>

单击链接后,会出现两个模态,输出 html 如下所示。

<div id="signup-modal">
  <div id="show-terms" class="modal hide fade in" style="display: block; ">
    <div class="modal-header">
    ...
  </div>
</div>

<div class="modal-backdrop fade in"></div>
<div class="modal-backdrop fade in"></div>

<div id="show-terms" class="modal hide fade in" style="display: block; ">
    <div class="modal-header">
    ...
</div>

编辑1

在我在 Heroku 上的登台应用程序中,模态运行良好。奇怪的是,在我上次推送 heroku 之后,我没有编辑任何与模式和注册页面相关的内容。我最近将操作系统更改为 Mountain Lion,因此它可能与操作系统有关。

编辑2

我做了“git push staging master”并尝试了模式是否可以正常工作,并且工作正常。很奇怪..

4

1 回答 1

2

It does this in your local environment most likely because your compiled assets that you need for Heroku are conflicting with the assets Rails includes on the fly when your in a development environment. To prevent this, you most likely need to just rm -rf public/assets to remove your precompiled assets. You should make sure to recompile them before every push to Heroku.

于 2012-08-01T12:51:33.153 回答