Greg Donald wrote:
> On Thu, Feb 11, 2010 at 12:58 PM, Marnen Laibow-Koser
> <[email protected]> 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.
OK. Perhaps I should have asked *when* you prefer RJS.
>
> 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
Hmm. Why the visual effect here, rather than in the completion handler
for the Ajax call? I guess I don't see the point of Rails writing JS,
rather than simply handing a JSON packet to the client.
I'll think about this further, though.
>
>>>> How do you keep the generated JavaScript out of your HTML?
>>>
>>> Partials.
>>>
>> Wouldn't that still put the JavaScript into your HTML files?
>
> Yup.
Which I don't like to do. Thanks for confirming that this is actually
the case.
>
>
> --
> Greg Donald
> destiney.com | gregdonald.com
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--
Posted via http://www.ruby-forum.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 [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.