Using Ajax to do more than 1 render


#1

Hello all ,
I am a newbie to rails but thanks to the tutorials I have created in
less
than a week’s time a dynamic ajax enabled test page which is shown to a
user
when he/she logs in. I am exploring the Javascript helper class and I
was
wondering if there is some way to update multiple portions of a web
page.

For example the page has a box on the right where in a user can add
some
tags.Now I need to update the portion of the page which shows a listing
of
all user tags and also another portion of a page whose content is
determined
by the tags added. I use the render :partial to update the first part
but I
am kind of clueless about how to acheive the second update.Any ideas?

Also does Rails provides a way to add a text box which basically
functions
like the form_remote_tag .But I want the text box to appear only when a
link
is clicked and also provide a link to hide it.I suspect i need to write
some
javascript here but I just want to know how far rails can take me.

thanks
vivek


#2

On 12/2/05, Vivek K. removed_email_address@domain.invalid wrote:

am kind of clueless about how to acheive the second update.Any ideas?

Also does Rails provides a way to add a text box which basically functions
like the form_remote_tag .But I want the text box to appear only when a link
is clicked and also provide a link to hide it.I suspect i need to write some
javascript here but I just want to know how far rails can take me.

thanks
vivek

Rails can take you all the way from here to the moon and back.

You’ll have to use #update_element_function [1] to update multiple
regions. RJS templates[2] make this a lot easier.

As for text boxes, scriptaculous provides the In-Place Editor [3].
Otherwise you can just write your own js to toggle the textbox on the
click of a link.

http://rails.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000430

http://rails.techno-weenie.net/tip/2005/11/29/ajaxed_forms_with_rjs_templates

  1. http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor


rick
http://techno-weenie.net