Thursday, February 11, 2010

[Rails] Re: repeated methods in rjs

Ok, does anyone know how to do a page[:div].replace_html on every ajax
call, helper or something like that?

On Feb 11, 1:15 pm, Greg Donald <gdon...@gmail.com> wrote:
> On Thu, Feb 11, 2010 at 12:58 PM, Marnen Laibow-Koser
>
> <li...@ruby-forum.com> wrote:
> > Why do you prefer RJS to writing JavaScript?
>
> RJS is a template rendering system that also happens to execute JS.  I
> do not prefer one over the other, it's apples and oranges.
>
> Controller action:
>
> def get_user
>   if request.xhr?
>     @user = User.find( params[:id] )
>   end
> end
>
> get_user.rjs:
>
> if @user
>   page.replace_html 'user_tab', :partial => 'user/user_form'
>   page << "$j( '#user_tab' ).fadeIn('slow');"
> end
>
> >>> How do you keep the generated JavaScript out of your HTML?
>
> >> Partials.
>
> > Wouldn't that still put the JavaScript into your HTML files?
>
> Yup.
>
> --
> Greg Donald
> destiney.com | gregdonald.com

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate