rubyonrailsin

A Ruby and Rails talk

Saturday, March 13, 2010


[Rails] render :partial and DOM manipulation

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hi guys,

I am stuck with something, I was hoping someone could point me in the
right direction...

In short:
- I need to render a bunch of partials (corresponding to models)
- I need to do some DOM logic on them (check if they already exist in
the page, insert them at the right place in the DOM hierarchy, etc)
- I need to do the above first following a standard call, and
subsequently after AJAX ones.

Right now I have two different methods for each type of call:
- standard: I render the partials inline in the view - it seems fine
and easy
- AJAX: I am trying to use render :update, but the DOM logic becomes
really difficult to write (with a lot of page <<
'javascript_and_prototype_stuff')

The fact I can't get the same method to work in both cases probably
mean I am missing something. Besides, in the AJAX case, the code
doesn't look very good at all (mixing js logic and Ruby), and it's a
lot more complicated than if I were to write plain javascript.

Is there a recommended/standard way to do this?

And as a side question: if I go for a pure javascript implementation,
I am going to miss the convenient render :partial method, isn't it? Or
is there a way to access it from javascript when it's rendered?

Thanks a lot,
Peter

--
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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive