小编gis*_*sek的帖子

带有jQuery的Ruby on Rails

嗨,我刚刚看到一篇关于如何将Rails与jQuery结合起来的文章.
http://blog.bernatfarrero.com/category/ror/
我按照说明操作但我无法使其工作(而不是使用ajax rails尝试非JavaScript方式处理请求).下载源代码后,我发现了问题所在.在public/javascripts的源代码中,有一个文件jquery-rails.js与该行连接

javascript_include_tag "jquery-rails.js" 
Run Code Online (Sandbox Code Playgroud)

在application.html.erb中.如果我在上面的行中更改该文件的名称,它将不再起作用.所以我试着将下载的驱动程序文件的原始名称更改为:http://docs.jquery.com/Downloading_jQuery#Download_jQuery(许多不同的版本)到我在源代码中找到的那个.当然我也把它放在同一个目录里.再次它无法工作......所以最后我比较了文件.我是这样的,来自源的文件要短得多.好吧,我是JS的真正初学者,所以我必须在这里请求你的帮助.为什么不起作用?如何使Rails与原始的jQuery驱动程序一起使用?
再见

您可以在下面看到来自源代码的'jquery-rails.js'

jQuery(function ($) {
var csrf_token = $('meta[name=csrf-token]').attr('content'),
    csrf_param = $('meta[name=csrf-param]').attr('content');

$.fn.extend({
    /**
     * Triggers a custom event on an element and returns the event result
     * this is used to get around not being able to ensure callbacks are placed
     * at the end of the chain.
     *
     * TODO: deprecate with jQuery 1.4.2 release, in favor of subscribing to our
     *       own events and placing ourselves …
Run Code Online (Sandbox Code Playgroud)

jquery ruby-on-rails

3
推荐指数
1
解决办法
1383
查看次数

标签 统计

jquery ×1

ruby-on-rails ×1