繁体   English   中英

Rails4 + Bootstrap3-模式渲染但不会显示

[英]Rails4 + Bootstrap3 - Modals render but won't show

我正在使用Rails 4,Bootstrap3。有问题的特定页面由3个haml视图组成。 第一个包含大部分页面内容。 第二个包含一行按钮-其中一个需要触发模式。 第三个包含模态。

第一个视图的代码是:

    <...bulk of page content...>
    = render partial: 'shared/buttons', locals: {diagram: @diagram}
    #showDetail.modal.fade{"aria-labelledby" => "showDetail", :role => dialog, :tabindex => "-1"}

第二个视图的代码(“共享/按钮”):

    <...links to several buttons that don't call modals...>
    = link_to "Show Detail", show_detail_path(item), class: "btn", data: {"toggle" => "modal", "target" => "#showDetail", "remote" => :true}

第三个视图的代码(items / _show_detail.html.haml,路由到“ show_detail_path”):

    .modal-dialog{:role => "document}
      .my_popup_contain
        .container-fluid
          <...rest of the code for the page...>

并在控制器中:

    def show_detail
      render partial: "show_detail"
    end

因此,使用此设置,单击按钮会生成页面“淡入淡出”,就像模态将要出现一样,但从不出现。 再次单击(任何位置)可使页面淡入淡出(就像显示模式时一样)。 Rails服务器日志显示模态确实呈现:

从2016年2月22日14:49:44 -0600开始为127.0.0.1获取GET“ / items / 4 / show_detail”,由ItemsController#show_detail作为JS参数处理:{“ id” =>“ 4”}用户负载(2.1 ms)选择“用户”。*从“用户”中,在“用户”。“ id” = 1排序由“用户”。“ id” ASC限制1项目加载(1.5ms)选择“项目”。*从“项目”在“ items”。“ type” IN(“ Item”)和“ items”。“ id” = $ 1 LIMIT 1 [[“ id”,4]]中呈现的项目/_show_detail.html.haml(1.1ms)已完成200 OK在11毫秒内(观看次数:4.7毫秒| ActiveRecord:3.6毫秒)

我想念什么? 视图之间的调用正确吗?

通过添加第一个视图的代码来解决此问题:

    <...bulk of page content...>
    = render partial: 'shared/buttons', locals: {diagram: @diagram}
    #showDetail.modal.fade{"aria-labelledby" => "showDetail", :role => dialog, :tabindex => "-1"}
      = render partial 'items/show_detail'

这调用了模式,并且所有工作都按预期进行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM