You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

需求:点击.box.boxAccounts容器跳转页面替代仅点击文本

Solution

To make the entire .box.boxAccounts container clickable instead of just the account text, you'll want to use Rails' link_to helper with a block—this lets you wrap the entire container in the anchor tag. Here's how to adjust your Haml code:

.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= account.name
                # Keep any other existing content inside .boxInsiteAccount here

What changed:

  1. Moved the link_to call to wrap the entire .box.boxAccounts div instead of just the account name text.
  2. Used the block syntax for link_to (passing a do...end block) which generates an <a> tag enclosing all content inside the block.
  3. Ensured the path (account_path(account)) points correctly to your account show page—adjust this if your route uses a different helper name.

Now, clicking anywhere within the .box.boxAccounts container (icon, text, or empty space inside the box) will trigger navigation to the account's page.

Quick note: If you have other interactive elements (like buttons or nested links) inside .box.boxAccounts, this might cause unexpected behavior since nested anchors aren't valid HTML. But assuming your box only contains static content (icon + account name), this approach works perfectly.

内容的提问来源于stack exchange,提问作者akin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:54:56