rails 3 does not render jquery properly

♀尐吖头ヾ 提交于 2020-01-17 07:57:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!