Jason Tuttle
2006-Apr-07 17:10 UTC
[Rails] Re: page.replace_html "#{var_containing_id_name}", :partial
Jeff Coleman <progressions@...> writes: > > Jason Tuttle 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
Chris Hall
2006-Apr-07 17:25 UTC
[Rails] Re: page.replace_html "#{var_containing_id_name}", :partial
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 On 4/7/06, Jason Tuttle <jason@gothamcitymacs.com> wrote:> > Jeff Coleman <progressions@...> writes: > > > > > Jason Tuttle 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060407/4a5b13a5/attachment.html
Jeff Coleman
2006-Apr-07 17:38 UTC
[Rails] Re: page.replace_html "#{var_containing_id_name}", :partial
Jason Tuttle wrote:> Jeff Coleman <progressions@...> writes: > > > > > Jason Tuttle 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. > > : ) > > JasonI just did some experimenting, and I got this work to just fine (adapting from Cody Fauser''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 -- Posted via http://www.ruby-forum.com/.