我在我的form_for中有一个选择选项。它在我安装物化之前工作,但在安装之后,它不再起作用了。请参阅下面的代码:
游戏模型
class Game < ActiveRecord::Base
GENRES = ['Action', 'Adventure', 'RPG', 'Simulation', 'Strategy', 'Sports', 'Others']
PLATFORMS = ['3DS', 'WII U', 'NX', 'PC', 'Playstation', 'XBOX', 'PS Vita', 'Mobile', 'Others']
end
new.html.erb
<h1> Add Game </h1>
<%= form_for :game, url: games_path do |f| %>
Title: <%= f.text_field :title %> <br />
Genre: <%= f.collection_select :genre, Game::GENRES, :to_s, :to_s, :include_blank => true %> <br />
Platform: <%= f.collection_select :platform, Game::PLATFORMS, :to_s, :to_s, :include_blank => true %> <br />
Release Date: <%= f.date_field :release_date %> <br />
Progress: <%= f.number_field :progress %> <br />
Rating: <%= f.number_field :rating %> <br />
<%= f.submit 'Add Game', class: 'add_game_button' %>
<%end%>
答案 0 :(得分:2)
MaterialiseCSS使用select
元素的自定义实现,您必须使用jQuery手动初始化:
$(document).ready(function() {
$('select').material_select();
});
有关详细信息,请查看MaterializeCSS docs。
答案 1 :(得分:0)
我只有两美分:
MaterializeCSS现在的版本为1.0.0,因此不是
$('select').material_select();
您将使用
$('select').formSelect();