问题
i have https://github.com/tkrotoff/jquery-simplecolorpicker-rails and i have tried https://github.com/tkrotoff/jquery-simplecolorpicker in plain HTML and the plain HTML worked.
I had swapped the code from the HTML to the one in rails but all my jquery functions does not work at all.
The file colorselect.js
$(function(){
$('#print_colorpaper').simplecolorpicker();
});
colorpaper.html.erb
<%= f.select(:colorpaper, Print::MY_COLORS, :selected => '#fbd75b') %>
the only thing i see in rails is the drop down menu which should be transformed into a palette as i see here: http://www.taqisystems.com/fiddle/
my application.js
//= require jquery
//= require jquery_ujs
//= require jquery.simplecolorpicker.js
//= require jquery.multi-select.js
//= require twitter/bootstrap
//= require_tree .
html source of the select:
<select id="print_colorpaper" name="print[colorpaper]"><option value="#7bd148">green</option>
回答1:
I have it working using the following: Try change in your app/assets/javascripts/application.js
jQuery(document).ready(function(){
jQuery('#print_colorpaper').simplecolorpicker();
});
来源:https://stackoverflow.com/questions/17624371/rails-3-does-not-render-jquery-properly