Forum: Ruby on Rails Problem: using will_paginate with Ajax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ruhul A. (Guest)
on 2009-01-17 10:05
I want to use pagination with ajax. I have used will_paginate then add
code to support ajax pagination.
I have tried with partial with when I use the code
in index.html.erb
<div id="container">
  <%= render :partial => 'contents' %>
</div>

Partial view: _contents.html.erb
<%= will_paginate @collection, :renderer => 'RemoteLinkRenderer',
:remote => {:update => 'container'} %>

in controller the index action :
 respond_to do |format|
      format.html { render :partial => 'container' }
      format.xml  { render :xml => @posts }
    end

and I am using the index action in the controller.
It just show only the partial not the total page with the partial
display.

Please help me
Patrick D. (Guest)
on 2009-01-19 04:07
(Received via mailing list)
On Sat, Jan 17, 2009 at 3:05 AM, Ruhul A. <
removed_email_address@domain.invalid> wrote:

> <%= will_paginate @collection, :renderer => 'RemoteLinkRenderer',
> display.
>
> Please help me
>
In my controller, I have:

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @documents }
      format.js do
        render :update do |page|
          page.replace_html('documents_table',
                            :partial => 'documents_table',
                            :locals  => {:documents => @documents})
        end
      end
    end

In index.html.erb, I have

<div id="documents_table">
  <%= render :partial => 'documents_table', :locals => {:documents =>
@documents} %>
</div>

That way, when I first render the page, I get the total page, but when I
click on the page number links I just update the div with the data.

Hope this helps.

--wpd
Ruhul A. (Guest)
on 2009-01-26 10:53
Patrick D. wrote:
> In my controller, I have:
>
>     respond_to do |format|
>       format.html # index.html.erb
>       format.xml  { render :xml => @documents }
>       format.js do
>         render :update do |page|
>           page.replace_html('documents_table',
>                             :partial => 'documents_table',
>                             :locals  => {:documents => @documents})
>         end
>       end
>     end
>
> In index.html.erb, I have
>
> <div id="documents_table">
>   <%= render :partial => 'documents_table', :locals => {:documents =>
> @documents} %>
> </div>
hi Patrick D.,
                 Thx for you reply.I have tried according to your code
but it don't display result but shows the
javascript code with the result. Below is the javascript that output in
the html page when I click the next link.

try { Element.update("votedtop20", " \n\n\n\n\n
\n \n \n hjbnj\n \n
\n \n
\n\n"); } catch (e) { alert('RJS error:\n\n' + e.toString());
alert('Element.update(\"votedtop20\", \" \\n\\n\\n\\n\\n
\\n \\n \\n hjbnj\\n \\n
\\n \\n
\\n\\n\");'); throw e }

Please help me.Thx in advance.
Amin
Patrick D. (Guest)
on 2009-01-26 16:40
(Received via mailing list)
On Mon, Jan 26, 2009 at 3:53 AM, Ruhul A. <
removed_email_address@domain.invalid> wrote:

> >                             :partial => 'documents_table',
> > </div>
> alert('Element.update(\"votedtop20\", \" \\n\\n\\n\\n\\n
> \\n \\n \\n hjbnj\\n \\n
> \\n \\n
> \\n\\n\");'); throw e }
>
> Please help me.Thx in advance.
> Amin
>
> Golly, I don't know.  I would guess that if you are seeing javascript in
your browser, then somehow you are not responding to a javascript
request,
but I really don't understand enough of how things work "under the hood"
to
know how that might happen.

--wpd
This topic is locked and can not be replied to.