开发者

will_paginate ajax pagination with thinking sphinx

开发者 https://www.devze.com 2023-01-16 02:40 出处:网络
Has anyone ever tried paginating a thinking sphinx result set thru ajax? I have this is in my controller action:

Has anyone ever tried paginating a thinking sphinx result set thru ajax?

I have this is in my controller action:

@results = Model.search params[:query], :page => params[:page] || 1, :per开发者_StackOverflow社区_page => 1

and in my application.js:

 $(".pagination a").live("click", function() {
   $.get(this.href, null, null, "script");
   return false;
 });

Now, I have tried this and this works for normal active record pagination like so:

@results = Model.paginate(:page => params[:page] || 1, :per_page => 1)

But if I use thinking-sphinx for getting the records the ajax pagination fails. Am I missing something?


I got this already. But for the next one who might encounter this problem, all you have to do is to make sure that the links also pass the params for the query.

= will_paginate(@results, :params=>{"query"=> params[:query]})
0

精彩评论

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

关注公众号