开发者

Ajax (pjax) pagination breaks after other ajax request

I am using pjax for main navigation and pagination (kaminari). Within the page I make ajax calls to change the state to some of the items on the page. The ajax call updates a partial which contains the pagination. The problem is that after an ajax request, the pjaxified pagination breaks. Instead of showing 开发者_Go百科the links to the next/previous pages, all the links in the pagination is now the same as the last ajax call.

Here's the template being called after the ajax request, toggle_state.js.erb:

$("#link-list").html("<%= escape_javascript(render 'links') %>")

Here's the partial 'links', being rendered after the ajax call:

<%= render @links %>
<%= paginate @links %>


Forcing some of the parameters set by the ajax request to nil made it work:

<%= paginate @links, :params => {:controller => 'links', :action => 'index', :id => nil, :toggle_to => nil} %>

It kind of makes sense when you think about it, but I also think there must be a more elegant way to do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜