# How can I use a rjs inside another rjs?

**URL:** <https://www.ruby-forum.com/t/how-can-i-use-a-rjs-inside-another-rjs/103779>\
**Category:** Rails\
**Created:** [May 10, 2007, 9:03am UTC](https://www.ruby-forum.com/t/how-can-i-use-a-rjs-inside-another-rjs/103779 "2007-05-10T09:03:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [May 10, 2007, 9:03am UTC](https://www.ruby-forum.com/t/how-can-i-use-a-rjs-inside-another-rjs/103779/1 "2007-05-10T09:03:33Z")

</div>

For example:

a.rjs  
page.insert\_html :bottom, :criteriaDiv, :partial =\> ‘criteria\_item’

b.rjs  
page.replace :keywordSearchLink, :partial =\>  
‘criteria\_item\_add\_link’, :locals =\> { :form\_name =\>  
‘keywordFieldset’}  
page.replace :propertySearchLink, :partial =\>  
‘criteria\_item\_add\_link’, :locals =\> { :form\_name =\>  
‘propertyFieldset’}  
page.replace :compositionSearchLink, :partial =\>  
‘criteria\_item\_add\_link’, :locals =\> { :form\_name =\>  
‘compositionFieldset’}  
page.insert\_html :bottom, :criteriaDiv, :partial =\> ‘criteria\_item’

As we can see, each of the rjs inserts the same content to the same  
part of the page. I can put the content to be inserted in a partial  
template, but putting the two “page.insert\_html” in one place should  
be better. How can I do this? Thanks a lot.
