# Rjs problem

**URL:** <https://www.ruby-forum.com/t/rjs-problem/109190>\
**Category:** Rails\
**Created:** [July 12, 2007, 10:03am UTC](https://www.ruby-forum.com/t/rjs-problem/109190 "2007-07-12T10:03:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 12, 2007, 10:03am UTC](https://www.ruby-forum.com/t/rjs-problem/109190/1 "2007-07-12T10:03:07Z")

</div>

Hi guys!

I have a form and list of elements added through this form on the same  
page. I am using rjs to add new elements, every new element is wrapped  
in an html tag with  
@element.dom\_id (dom\_id plugin) so i can also delete and edit using rjs.  
I’ve also added a pagination using the plugin will\_paginate. This part  
works great.

I don’t want to make rjs pagination(because of “back” button problems).  
The problem is when i add another element (when i already have limited  
number of elements on a page by will\_paginate) the rjs will ofcourse add  
another element to the top of element list and this will exeed the  
number of elements that should be on the page at once.

What i want is rjs to remove the oldest element(lowest id of the element  
on current page i guess) when the limit exceeds per page pagination  
limit so the user will always see the right amount of elements on the  
page.

thanks

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [November 13, 2007, 11:48am UTC](https://www.ruby-forum.com/t/rjs-problem/109190/2 "2007-11-13T11:48:45Z")

</div>

Hi Pawel,

Any luck with the probelm. I am facing a similar situation.

Regards,  
Sandeep G

Pawel Jur wrote:

> Hi guys!
> 
> I have a form and list of elements added through this form on the same  
> page. I am using rjs to add new elements, every new element is wrapped  
> in an html tag with  
> @element.dom\_id (dom\_id plugin) so i can also delete and edit using rjs.  
> I’ve also added a pagination using the plugin will\_paginate. This part  
> works great.
> 
> I don’t want to make rjs pagination(because of “back” button problems).  
> The problem is when i add another element (when i already have limited  
> number of elements on a page by will\_paginate) the rjs will ofcourse add  
> another element to the top of element list and this will exeed the  
> number of elements that should be on the page at once.
> 
> What i want is rjs to remove the oldest element(lowest id of the element  
> on current page i guess) when the limit exceeds per page pagination  
> limit so the user will always see the right amount of elements on the  
> page.
> 
> thanks
