0

This isn't making ajax call. I guess its the javascript, on the console the request shows as 'html' rather than 'JS'. I have similar javascripts working for other ajax, but dont know what is wrong here.

_list_page.html.erb

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

JS gets rendered in list_page.js.erb file -

$(".pagination a").click(function() {
        $.ajax({
          type: "GET",
          url: $(this).attr("href")
        });
        return false;
    });

EDIT: Tried jQuery bind, didn't work. For some reason click event is no binding with the element.

$(".pagination a").bind('click', function(event) {
alert('User clicked on "test"'); # Even this isn't working
 $.ajax({
          type: "GET",
          url: $(this).attr("href")
        });
        return false;
    });
4

2 に答える 2

1

will_paginate で明示的に ajax 呼び出しを行っている理由がわかりません。この機能は、この gem に組み込まれています。:renderer => "RemoteLinkRenderer" を使用して ajax 呼び出しにすることができます。

お気に入り :

<%= will_paginate @events, :renderer => "RemoteLinkRenderer",:remote => {, :update => "events_container", :loading => visual_effect(:appear, "loader"),:complete =>visual_effect(:fade,"loader" ) } %>

詳細については、http ://www.botvector.net/2008/08/willpaginate-on-ajax.html をご覧ください。

于 2012-05-11T05:50:24.757 に答える