2016-07-03 3 views
0

레일의 form_for에 선택 옵션이 있습니다. 내가 설치하기 전에 작동하지만 설치 한 후에 더 이상 작동하지 않습니다. 아래에 내 코드를 참조하십시오 :MaterializeCSS를 사용하는 레일에서 선택 옵션이 작동하지 않습니다.

게임 모델

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%> 

답변

1

MaterializeCSS 당신이 jQuery를 사용하여 수동으로 초기화해야한다는, select 요소의 사용자 지정 구현을 사용합니다 :

$(document).ready(function() { 
    $('select').material_select(); 
}); 

자세한 내용은을 참조하십시오..

관련 문제