Hi Fred, thanks so much for your response, that is exactly what I was
looking for.  What do you mean by rjs can be a bit of a crutch?  What
do you mean by rewriting the whole thing as a js function.  You mean
just something like resetVisibility() and then just reset both the
end_drop and start_drop elements within the resetVisibility function?

Thanks for your help, Dave

On Feb 11, 4:17 am, Frederick Cheung <[email protected]>
wrote:
> On 11 Feb 2009, at 10:41, David wrote:
>
>
>
>
>
> > 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';
> >          }"
>
> Yummy :-). if you're using prototype you can replace
>
> $('end_drop_foo').style.display = 'block';
> $('end_drop_foo').style.visibility = 'hidden';
>
> with
>
> $('end_drop_foo').setStyle({display: 'block', visibility: 'hidden'})
>
> If i were you I'd have in my application.js a function like
>
> function resetVisibility(element){
>    element.setStyle({display: 'block', visibility: 'hidden'})
>
> }
>
> then then your rjs stuff looks like
>
> resetVisibility('end_drop_#{params[:day]}_#{params[:appt_counter]}')
> resetVisibility('start_drop_#{params[:day]}_#{params[:appt_counter]}')
>
> or even right the whole thing as a js function (RJS can be a bit of a  
> crutch)
>
> Fred
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to