Bootstrap模式显示两次

问题描述:

在我的Rails应用程序中,我使用Twitter引导程序。Bootstrap模式显示两次

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

色器件/注册/ 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> 

EDIT1

在在Heroku上,模态做工精细我升级的应用程序。 奇怪的是,我上次推Herku后没有编辑与模式和注册页面相关的任何内容。 我最近将操作系统更改为Mountain Lion,因此它可能与操作系统有关。

EDIT2

我做“混帐推分期主”和尝试,如果模式将正常工作,并且工作正常。 非常奇怪..

它在您的本地环境中这样做很可能是因为您需要用于Heroku的编译资产与资产相冲突当您在开发环境中时,Rails包括在运行中。为了防止这种情况发生,您最有可能只需要rm -rf public/assets即可删除预编译的资产。在每次推送到Heroku之前,您都应该确保重新编译它们。

+0

我试过你的解决方案,现在模态在我的本地服务器上正常工作,谢谢。我认为我的载波和环境设置有问题。导致我在尝试资源时不断收到错误:预编译。不管怎样,谢谢! – 2012-08-02 02:48:01

+0

如果我的答案是解决您的问题,请随时查看绿色箭头。 :d – John 2012-08-02 03:01:20