开发者

Rails application <select> display overwritten

开发者 https://www.devze.com 2023-02-28 19:36 出处:网络
I have a Rails 3 application set to use HTML5. I previously programmed a select tag to display some values from an active record query. Now when I run the application thedefault display is being set t

I have a Rails 3 application set to use HTML5. I previously programmed a select tag to display some values from an active record query. Now when I run the application the default display is being set to none though I do not开发者_如何学Python have that style attribute set in any of the application stylesheets. Even when I use in-line styling such as

<div id="models">
  <select style="display:block;">
    <% @models.each do |model| %>
        <option value="<%= model.id %>" ><%= model.name %></option>
        <% end %>
     </select>
   </div>

the element's style attribute is still being set to "display: none;".

Do anyone have any suggestions?


I would recommend trying collection_select, something like:

collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})

e.g.

collection_select(:model, :name, Model.all, :id, :name, {:prompt=>true}, {:class=>'my-class'})

and set my-class in your stylesheet.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号