0

Last 6 hours I am trying to get this working. I tried several code examples but none of them seem to work. I read will_paginate is not designed for rails 3. I got it working to a point where it does pagination but cannot make ajax requests. Tried JQuery to help that ajax problem , no luck there too. This is odd, doesn't take this much try to a small thing working. Pagination is happening but it has to make an ajax call. I really need some good advice here before I go crazy.

View -

<div id="digg_pagination">
    <div class="page_info">
      <%= page_entries_info @list_page %>
    </div>
        <%= will_paginate(@list_page , :container => true, :remote => true,  :page_links => true ) %>
</div>

Generates HTML -

<div id="digg_pagination">
    <div class="page_info">
      Displaying Item<b>2&nbsp;-&nbsp;2</b> of <b>2</b> in total
    </div>
        <div class="pagination" remote="true">
  <a class="previous_page" rel="prev start" href="/item/item_list?page=1">&#8592; Previous</a> 
  <a rel="prev start" href="/item/item_list?page=1">1</a> 
  <em class="current">2</em> <span class="next_page disabled">Next &#8594;</span>
</div>
</div> 

JS -

$(function(){
$('#item_list').html(<%= (render :partial => 'item_list').to_json.html_safe %>);
$('.pagination a').attr('data-remote', 'true'); # Doesn't add the html attribute 
$('.pagination a').livequery('click', function() {
        $.getScript(this.href);
        return false;
});
}); #Tried bind 'click', live, livequery. none worked. 
Viktor Trón
  • 8,774
  • 4
  • 45
  • 48
Majoris
  • 2,963
  • 6
  • 47
  • 81

1 Answers1

0

This works for me:

# in a generic js
$(document).ready(function () {
    $(".pagination").find("a").livequery(function () {
        $(this).attr("data-remote", true);
    });
});

will_paginate(collection, :remote => true) not yet accepted https://github.com/mislav/will_paginate/pull/100

Viktor Trón
  • 8,774
  • 4
  • 45
  • 48