Created
May 10, 2015 12:50
-
-
Save anonymous/e6b56f1bccf754a865eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="participations" data-no-turbolink> | |
<h2><%= participation.user.name %></h2> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="row"> | |
<div id="participations"> | |
<%= render @participations %> | |
</div> | |
<%= will_paginate @participations %> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#participations').append('<%= j render(@participations) %>'); | |
<% if @participations.next_page %> | |
$('.pagination').replaceWith('<%= j will_paginate(@participations) %>'); | |
<% else %> | |
$('.pagination').remove(); | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).scroll -> | |
#Return right away if we're busy loading next set | |
return if(window.pagination_loading) | |
url = $('.pagination .next_page').attr('href') | |
console.log "url is undefined: url #{url}" | |
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50 | |
#Note that we're loading data set | |
window.pagination_loading = true | |
#load as before but attach callback to clear falg when we're done. | |
$('.pagination').text('Fetching more products...') | |
$.getScript(url).always -> | |
window.pagination_loading = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment