# Refactoring RJS

**URL:** <https://www.ruby-forum.com/t/refactoring-rjs/160058>\
**Category:** Rails\
**Created:** [February 11, 2009, 11:41am UTC](https://www.ruby-forum.com/t/refactoring-rjs/160058 "2009-02-11T11:41:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [February 11, 2009, 11:41am UTC](https://www.ruby-forum.com/t/refactoring-rjs/160058/1 "2009-02-11T11:41:55Z")

</div>

I have some RJS that could use some refactoring. I use the function  
called with afterFinish twice and Im wondering what the best way to  
refactor is. This is all inline rjs in the controller mind you:

```
      page.visual_effect :slide_down, "add_appt_#{params

```

[:day]}", :afterFinish =\> “function(){  
$(‘end\_drop\_#{params[:day]}_#{params  
[:appt\_counter]}’).style.display = ‘block’;  
$('end\_drop_#{params[:day]}_#{params  
[:appt\_counter]}’).style.visibility = ‘hidden’;  
$('start\_drop_#{params[:day]}_#{params  
[:appt\_counter]}’).style.display = ‘block’;  
$('start\_drop_#{params[:day]}\_#{params  
[:appt\_counter]}’).style.visibility = ‘hidden’;  
}”
