首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gmaps4rails :使用Bootstrap模式与gmaps4rails infowindow

Gmaps4rails :使用Bootstrap模式与gmaps4rails infowindow
EN

Stack Overflow用户
提问于 2013-09-26 09:27:12
回答 1查看 540关注 0票数 1

我已经设法在我的应用程序中应用了gmaps4rails

第一方法

我有一个像这样的map动作:

代码语言:javascript
复制
def map
  @family = Family.all.to_gmaps4rails do |family,marker|
    marker.infowindow render_to_string(:partial => "/layouts/info", :locals => { :family => family})
  end
end  

在我的_info.html.erb:里

代码语言:javascript
复制
<h5><%=family.location%></h5>

<%=link_to "View Details","#myModal",class: "btn btn-success",data: {toggle: "modal"} %>

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel" style="color:#9D5641;margin-top:10px;">Family Details</h3>
        <h5>Family ID : <%=family.famid%></h5>
    </div>
    <div class="modal-body">
        <%= family.persons.count %>
        <table class="table table-hover">
            <tr>
                <th>Name</th>
                <th>Mobile No.</th>
                <th>Photo</th>
            </tr>
            <% family.persons.each do |person| %>
                <tr>
                    <td><%=person.name%></td>
                    <td><%=person.mobnum%></td>
                    <td><%=person.photo%></td>
                </tr>
            <%end%>
        </table>
    </div>
    <div class="modal-footer">
        <h5><%=link_to "Veiw Full Details", {controller: :managedb ,action: :details, famid: family.famid} %></h5>
    </div>
</div>  

引导的模式是很好的,但有一个小故障。看起来是这样的:

grey 模式应该位于颜色层的顶部。

我猜这是在发生,因为infowindow部分中呈现modal。这就是为什么css属性是infowindow的原因。如何使它像正常的modal一样工作。

我可以删除background-color,一旦激活了模态,就可以添加以下内容:

模式-背景{背景:无;}

我的css文件。

但**模式不是clickable。我不能点击其中的链接,所以on.How可以修复这个问题吗?

替代方法--我尝试过

地图动作

代码语言:javascript
复制
    def map
        @family = Family.all.to_gmaps4rails do |family,marker|
            @fam=family
            marker.infowindow render_to_string(:partial => "/layouts/map", :locals => { :family => family})
        end
    end  

_info.html.erb

代码语言:javascript
复制
<h5><%=family.location%></h5>

<%=link_to "View Details","#myModal",class: "btn btn-success",data: {toggle: "modal"} %>  

map.html.erb

代码语言:javascript
复制
<div class="container">
<div class="row">
    <%= gmaps4rails(@family) %>
    <!-- Modal -->
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel" style="color:#9D5641;margin-top:10px;">Family Details</h3>
            <h5>Family ID : <%=@fam.famid%></h5>
        </div>
        <div class="modal-body">
            <table class="table table-hover">
                <tr>
                    <th>Name</th>
                    <th>Mobile No.</th>
                    <th>Photo</th>
                </tr>
                <% @fam.persons.each do |person| %>
                    <tr>
                        <td><%=person.name%></td>
                        <td><%=person.mobnum%></td>
                        <td><%=person.photo%></td>
                    </tr>
                <%end%>
            </table>
        </div>
        <div class="modal-footer">
            <h5><%=link_to "Veiw Full Details", {controller: :managedb ,action: :details, famid: @fam.famid} %></h5>
        </div>
    </div>
</div>

现在,modal 正确地呈现,但它只有@fam变量中的最后一个family

如何从模态的链接中将family id 作为参数传递给?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-26 13:54:38

最后我用第一种方法做了这件事。

改变了modal的少量css属性

代码语言:javascript
复制
.modal-backdrop {background: none;z-index:-1;}  

代码语言:javascript
复制
#myModal {z-index:1;}  

现在,模态中的所有元素都是可点击的,就像普通的引导模态一样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19024350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档