【问题标题】:click on box to go to the next page instead of clicking on only text [closed]单击框转到下一页,而不是仅单击文本[关闭]
【发布时间】:2018-09-29 15:31:45
【问题描述】:

我这里有一个代码,您可以在其中单击(帐户)文本。这将打开下一页。

我想拥有:当您单击 (.box.boxAccounts) 时,您会转到下一页,而不仅仅是文本 (account) =Link_to 返回帐户名称。

.features-boxed
  .container.boxContainer
    #myUL.row.features.appFunction.indexBox
      - @accounts.sort_by(&:name).each do |account|
        .col-sm-6.col-md-5.col-lg-3.item.icons
          .box.boxAccounts
            .boxInsiteAccount
              %i.fa.fa-building.iconSpaceBottom.accountIcon
              %h3.name
              = link_to account.name, account_path(account), :class => "optieTekst"
              %br/

【问题讨论】:

标签: html ruby-on-rails ruby bootstrap-4 haml


【解决方案1】:

那么我们不只是将链接包装在盒子周围吗?

.features-boxed
  .container.boxContainer
    #myUL.row.features.appFunction.indexBox
      - @accounts.sort_by(&:name).each do |account|
        .col-sm-6.col-md-5.col-lg-3.item.icons
          = link_to account_path(account) do
            .box.boxAccounts
              .boxInsiteAccount
                %i.fa.fa-building.iconSpaceBottom.accountIcon
                %h3.name
                = account.name
                %br/

【讨论】:

  • 啊,是的,完全忘记了 xd 我的错。谢谢,虽然它帮助了我:)
【解决方案2】:

link_to 占用一个块。

你可以试试:

- @accounts.sort_by(&:name).each do |account|   
  .col-sm-6.col-md-5.col-lg-3.item.icons
    = link_to account_path(account) do
      .box.boxAccounts
        .boxInsiteAccount
          %i.fa.fa-building.iconSpaceBottom.accountIcon
          %h3.name
          = account.name
          %br/

【讨论】:

    猜你喜欢
    • 2015-12-25
    • 1970-01-01
    • 2011-05-19
    • 1970-01-01
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    相关资源
    最近更新 更多