jquery - Will paginate and endless page - from tutorial -
i made endless page scroll tutorial http://railscasts.com/episodes/114-endless-page-revised?view=asciicast , works.
but problem javascript run endless page every paginate - on other pages - example, try endless paginate messages box.
script simple think, im nobie in javascript , dont know how tell script endless scroll on selected page , not every will_paginate on project. see in js file $('.paginate) - tell script run every paginate class.
i grateful tip.
js in erb:
$('.profile_list').append('<%= j render(@users) %>'); <% if @users.next_page %> $('.pagination').replacewith('<%= j will_paginate(@users) %>'); <% else %> $('.pagination').remove(); <% end %>
and js js file:
if ($('.pagination').length) { $(window).scroll(function() { var url; url = $('.pagination .next_page').attr('href'); if (url && $(window).scrolltop() > $(document).height() - $(window).height() - 50) { //$('.pagination').text('fetching more products...') $.getscript(url)
well try including js in pages want, remove application.js file , add manualy on page this:
javascript_include_tag "yourjs.js"
here example in question: rails 3.1 pipeline - exclude javascript file
read checked answer
Comments
Post a Comment