내 form_for in rails에 선택 옵션이 있습니다. materialize를 설치하기 전에 작동했지만 설치 후 더 이상 작동하지 않습니다. 아래 내 코드를 참조하십시오.
게임 모델
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%>
MaterializeCSS는 select
jQuery를 사용하여 수동으로 초기화해야하는 요소 의 사용자 지정 구현을 사용합니다 .
$(document).ready(function() {
$('select').material_select();
});
자세한 내용은 MaterializeCSS 문서를 확인하십시오 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다