【问题标题】:How to render images in rails3 select如何在rails3中渲染图像选择
【发布时间】:2013-03-09 12:18:49
【问题描述】:

我想以图像作为选项的形式呈现下拉列表。如何在 rails3 中实现这一点?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 actionview actionviewhelper


    【解决方案1】:

    查看这个插件http://www.marghoobsuleman.com/jquery-image-dropdown 没有选项可以直接在 Rails 中进行。

    【讨论】:

      【解决方案2】:

      我喜欢msdropdown。您可以在title标签中添加图片的路径:

      <select>
        <option value="1" title="#path for the image">first</option>
        <option value="2" title="#path for the image">second</option>
         ...
      </select>
      

      在 Rails 中,您可以添加标题,如下所示:

      <%= f.select(:yourcolumn, Model.all.map{|p| [p.name, p.id, :title => p.image_url(:thumb)]}
      

      前段时间我也遇到过类似的问题:generate HTML <select> with title inside each <option> to apply the msDropDown plugin

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-12-11
        • 1970-01-01
        • 1970-01-01
        • 2021-01-01
        • 2011-10-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多