在Ruby on Rails中使用jquery.pageless的undefined方法`pageless'

时间:2013-09-05 01:15:22

标签: javascript ruby-on-rails ruby infinite-scroll

我正在尝试使用jquery.pageless

实现无限滚动

但是我收到了这个错误:undefined method 'pageless'

我在资产中的application.html.erb中包含了jquery.pageless.js:

<%= javascript_include_tag 'jquery-1.3.2.min', 'jquery.pageless' -%>

有关如何解决这个问题的任何建议吗?

2 个答案:

答案 0 :(得分:1)

我不知道你为什么使用这种格式:

<%= javascript_include_tag 'jquery-1.3.2.min', 'jquery.pageless' -%>
在application.rb中

在assets / javascript / application.js中,添加以下文件:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jqeury.pageless
//= require jquery_ujs
//= require_tree .

您需要确保安装了jquery:

gem install jquery-rails

然后:

bundle install

还要确保在application.js文件中提到的路径中有jquery-pageless.js文件,以便资产管道获取它。

答案 1 :(得分:0)

Application.js文件:

    // This is a manifest file that'll be compiled into application.js, which will include all the files
    // listed below.
    //
    // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
    // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
    //
    // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
    // compiled file.
    //
    // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
    // about supported directives.
    //
    //= require jquery
    //= require jquery.pageless
    //= require jquery_ujs
    //= require turbolinks
    //= require_tree .