On Mar 13, 5:01 pm, PierreW
<wamre...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> 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?
>
You may find things a little easier with a little more actual
javascript, eg have your action render the same html fragments but
then use the onSuccess/onComplete callbacks (assuming you are using
prototype) to sort stuff out clientside (be careful which one you use
- Ajax.Updater uses one of these to insert its content, so if you use
the wrong one your callback runs before the dom has been updated). I''m
not entirely sure what you are doing but you could have your ajax
updates appear in a hidden div and move elements out of there into the
page.
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.