jtoy
April 7, 2006, 7:12pm
1
Jeff C.man <progressions@…> writes:
Jason T. wrote:
The subject line says it all. – Is there a way to do something
like:
page.replace_html “#{var_containing_id_name}”, :partial => ‘edit’
That line of code does not work, but I would like to pass the
name of
a variable to page.replace_html. This variable would contain the id
of the div I want to update.
Anyone know if/how I could do that?
Thanks!
: )
Jason
Convert the string with the ID name to a symbol?
page.replace_html var_containing_id_name.to_sym, :partial => ‘edit’
perhaps?
Jeff
Thanks for the idea Jeff. – Unfortunately, it doesn’t seem to work.
: )
Jason
jtoy
April 7, 2006, 7:27pm
2
you mean like this?
def do_some_ajax_thing
@element_id = “content_div”
end
do_some_ajax_thing.rjs
page.replace_html @element_id , :partial => “edit”
remember, the view templates have access to the attributes defined in
the
controller
jtoy
April 7, 2006, 7:38pm
3
Jason T. wrote:
Jeff C.man <progressions@…> writes:
Jason T. wrote:
The subject line says it all. – Is there a way to do something
like:
page.replace_html “#{var_containing_id_name}”, :partial => ‘edit’
That line of code does not work, but I would like to pass the
name of
a variable to page.replace_html. This variable would contain the id
of the div I want to update.
Anyone know if/how I could do that?
Thanks!
: )
Jason
Convert the string with the ID name to a symbol?
page.replace_html var_containing_id_name.to_sym, :partial => ‘edit’
perhaps?
Jeff
Thanks for the idea Jeff. – Unfortunately, it doesn’t seem to work.
: )
Jason
I just did some experimenting, and I got this work to just fine
(adapting from Cody F.'s template example:
add.rjs:
page.insert_html :bottom, ‘list’,
content_tag(“li”, “Fox”)
page.visual_effect :highlight, ‘list’, :duration => 3
var_containing_id_name = ‘animals’
page.replace_html var_containing_id_name,
‘RJS Template Test Complete!’
Where is your var_containing_id_name defined? If it’s defined in your
controller, then try using an instance variable,
@var_containing_id_name . Your view templates won’t have access to any
local variables defined in your controller.
Jeff