We are currently developing in the following environments:
Ruby: 2.3.1
Rails:5.0.0
I am using MaterializeCSS, but the Select box does not work.It appears, but cannot be pulled down.
Many research shows that adding JavaScript code solves the problem, but we have verified that JavaScript code has been added and that the code itself is running.
1.VIEW (test.html.slim)
=form_for@test,html: {class:'cols12'} do | f |
.input-field.col.s6
= f.select:topic, Test::TOPICS, {:prompt=>'}, :id=>'topic_area'
label [ for = "topic_area" ]
| topic
*Test is a model with an array called TOPICS defined.
2.Generated HTML
<form class="cols12" id="new_test" action="/test" accept-charset="UTF-8" method="post">
<div class="input-field cols6">
<select id="topic_area" name="test[topic]">
<option value=""></option>
<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
</select>
<label for="topic_area">topic</label>
</div>
</form>
3.JavaScript (Common.js)
$( document).ready(function(){
$('select').material_select();
});
By the way, if you specify the class "browser-default" in the Select box, it will work.
Also, JavaScript (jQuery), including Materialize's JS, is a recognition that reads JavaScript (jQuery) without any problems, since the parts that use JavaScript other than the Select box are working fine.
Also, I am using Bootstrap, but can you think of compatibility issues?
That's all.I would appreciate it if you could let me know.Thank you for your cooperation.
ruby-on-rails ruby css
Bootstrap is competitive, so I suggest you narrow it down to one or the other.
Nav etc. will also compete, so please be careful.
Also be aware of the /assets/stylesheets/scaffold.css
that will be generated if you create something with scaffold.
© 2024 OneMinuteCode. All rights reserved.