Trying to follow the guide of railscast 114 with the endless page using will_paginate
but I get an error from my coffeescript:
home.js.coffee
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').text("Fetching more products...")
$.getScript(url)
$(window).scroll()
On the line:
if $('.pagination').length
I get the following error:
Uncaught TypeError: Cannot read property 'length' of null
It seems like the script does not read my index file because the script can't find any of my div-boxes...
Please help... been stuck with this problem of the endless page for a week now.
Update coffeescript
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').text("Fetching more products...")
$.getScript(url)
$(window).scroll()