Rails 3无法正确呈现jquery [英] rails 3 does not render jquery properly

查看:92
本文介绍了Rails 3无法正确呈现jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 https://github.com/tkrotoff/jquery-simplecolorpicker-rails并且我已经尝试使用纯HTML格式的 https://github.com/tkrotoff/jquery-simplecolorpicker 普通的HTML起作用了.

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.

我已经将HTML中的代码交换为rails中的代码,但是我所有的jquery函数都不起作用.

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

colorpaper.html.erb

<%= f.select(:colorpaper, Print::MY_COLORS, :selected => '#fbd75b') %>

我在rails上唯一看到的是下拉菜单,应该将其转换为调色板,就像我在这里看到的一样: http://www.taqisystems.com/fiddle/

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/

我的application.js

my application.js

//= require jquery
//= require jquery_ujs
//= require jquery.simplecolorpicker.js
//= require jquery.multi-select.js
//= require twitter/bootstrap
//= require_tree .

选择的html来源:

    <select id="print_colorpaper" name="print[colorpaper]"><option value="#7bd148">green</option>

推荐答案

我使用以下方法进行工作: 尝试更改您的app/assets/javascripts/application.js

I have it working using the following: Try change in your app/assets/javascripts/application.js

    jQuery(document).ready(function(){
       jQuery('#print_colorpaper').simplecolorpicker();
    });

这篇关于Rails 3无法正确呈现jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆