【问题标题】:Rails 3 - Thumbs_up - customized buttonRails 3 - Thumbs_up - 自定义按钮
【发布时间】:2011-04-03 18:38:39
【问题描述】:

嗨 我已经安装了 Thumbs_up gem,效果很好。

但现在我想做一个与此功能相同的按钮。

<%= link_to('vote for this post!', vote_up_retailer_path(@retailer), :remote => true, :method => :post) %>

我遇到的问题是我想要按钮内的图像和文本,并带有文本“Like ”,(就像 youtubes like button)。

我的按钮是这样编码的。`

<button role="button" class="like">
  <img src="/images/layout/blank.gif"><span>Like <%= @retailer.title %></span>
</button>

如何在 rails3 中使用这些功能完成按钮?

提前致谢,

【问题讨论】:

    标签: ruby-on-rails-3 rubygems customization vote-up-buttons


    【解决方案1】:

    我不确定我是否理解正确,但要在文本中添加变量,您可以这样做:

    link_to "vote for this #{@retailer.title}" ...
    

    对于图片,您可以使用 image_tag :

    http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag

    【讨论】:

    • 您好,感谢您的快速回复,我猜您的回答是解决方案的一部分。我希望 rails 呈现我粘贴在问题“
    • 将所有内容都包裹在 link_to 周围。只需添加您拥有的 html,并在跨度内添加您的 link_to,如我所示:)
    • 您好,我已将其更改为此,但单击按钮时不会注册任何投票。
    • 尝试不使用遥控器并检查您发布的操作。
    • 您好试过了,它没有做任何事情,就像按钮接管并且不应用链接?感谢您的所有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 2023-03-22
    相关资源
    最近更新 更多