Haml link_to imbrication

时间:2014-02-28 09:15:06

标签: twitter-bootstrap ruby-on-rails-4 haml link-to

对于rails环境来说还是一个新手,我正在尝试将链接呈现为另一个 我想重现 list-group-custom-content 组件

这是很好渲染的haml内容

%div{:class => ["list-group"]}
    - @tickets.each do |ticket|
        = link_to "#", :class => "list-group-item" do
            %div.row
                %div{:class => "col-sm-8"}
                    %h4{:class => "list-group-item-heading"}
                        Blabla
                    %p{:class => "list-group-item-text"}
                        blabla bla blabla
                %div{:class => "col-sm-4"}
                    other content

The corresponding rendered html

以下是将失败的haml内容

%div{:class => ["list-group"]}
    - @tickets.each do |ticket|
        = link_to "#", :class => "list-group-item" do
            %div.row
                %div{:class => "col-sm-8"}
                    %h4{:class => "list-group-item-heading"}
                        = link_to ticket.subject, "#"        -# <- Here is the problem
                    %p{:class => "list-group-item-text"}
                        blabla bla blabla
                %div{:class => "col-sm-4"}
                    other content

The corresponding rendered html

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

似乎问题不是来自我的haml模板。 这是渲染的html

<div class='list-group'>
    <a class="list-group-item" href="#">
        <div class='row'>
            <div class='col-sm-8'>
                left
            </div>
            <div class='col-sm-4'>
                <p class='pull-right'>
                    <a href="#">Close</a> <!-- This link cause problem -->
                </p>
            </div>
        </div>
    </a>
    <a class="list-group-item" href="#">
        <div class='row'>
            <div class='col-sm-8'>
                left
            </div>
            <div class='col-sm-4'>
                <p class='pull-right'>
                    <a href="#">Close</a> <!-- This link cause problem -->
                </p>
            </div>
        </div>
    </a>
</div>

只要我插入标记为导致问题的链接,布局就会完全被破坏 如果我用

替换链接
<button>Close</button>

有效 这是一个引导问题还是没有被支持的东西?

我应该关闭这个问题并开一个新问题吗?