未定义的方法`pageless'在RubyonRails中使用jquery.pageless

undefined method `pageless' using jquery.pageless in Ruby on Rails

本文关键字:pageless RubyonRails jquery 方法 未定义      更新时间:2023-09-26

我正在尝试实现一个无限滚动,并使用jquery.pageless

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

我在assets:中的application.html.erb中包含jquery.pageless.js

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

关于如何解决这个问题,有什么建议吗?

我不知道您为什么要使用以下格式:

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

应用程序.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文件,以便它被资产管道获取。

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 .