On 29 Oct 2008, at 09:56, Subhadip Chakraborty wrote:
>> Which version of gem r u using?
>> In controller you can do like
>> @user = User.paginate :page => params[:page], :per_page => 2
>> and in view you can do
>> <%= will_paginate
>> @user
>> ,:update
>> =
>> >
>> 'GeneralDiv
>> ',:params
>> =>{:controller=>'userinfo',:action=>'showuser',:sd_id=>@sd_ticket},
>> :container => false %>
>>
>> I dont know why you use :complete=>"Element.show('GeneralDiv');"
>>
>> Also pass the params (if any) to will_paginate in view..And restart
>> your server also.
>>
>> Sijo
>
> thanks,Sijo,
> but the problem is still pending.when i click on next page link,
> total page is refresh like normal pagination.
> here is my code,
>
> <%= will_paginate @user, :update=>'GeneralDiv',
> :params=>{:controller=>'userinfo',:action=>'showuser'},
> :container => false %>
> can i call the same function 'showuser' every time .
> the div is replaced after refreshing of total page,can i stop
> this page refresing,this is not possible using this code.
> beside that i am using rails version 2.1.1.
I just don't understand why people want to make it so hard on
themselves. I know for a fact that will_paginate wraps the pagination
links in a <div> with a class you can use, called "pagination". In
your application.js file, you just put the following (I've also
provided a link to a syntax highlighted pastie below, easier to read):
document.observe("dom:loaded", function() {
// pagination is the class will_paginate wraps around the links
// let's keep the number of observers limited to one, your browser
will thank you
$$('.pagination').observe('click', function(e) {
var clicked = $(e.target);
// time to see if the clicked item was indeed one of the links
if(clicked.match('a')) {
// if it was, stop the default page refresh and fire an ajax
request instead
// let's not forget a RESTful design wants use to use GET
instead of the default POST method
e.stop();
new Ajax.Request(clicked.href, {method: 'get'});
}
});
}
http://pastie.org/303029
The code is untested, but looks to me like I didn't make a mistake.
You could even take the event delegation a bit further and put it on
the window element, but that's up to you guys to experiment with.
Best regards
Peter De Berdt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---