Hi, I''m using the "link_to_remote" AJAX function call from my "view", and what i want is after i get the results from the function call, I want to update the result directly into to an image ie. <IMG> tag, how to do this.?? ie. if we want to update the result into a ''div'' element we do like this, which works fine.. link_to_remote(:update => ''updatediv'', :url => { :action => :my_method }) But i want to update the output which is an ''Image'' in my case into a HTML IMG tag and display it in the browser. I want to go only for <img> tag.. Thank You Dinesh -- Posted via http://www.ruby-forum.com/.
Guest wrote:> Hi, > > I''m using the "link_to_remote" AJAX function call from my "view", and > what i want is after i get the results from the function call, I want to > update the result > directly into to an image ie. <IMG> tag, how to do this.?? > > ie. if we want to update the result into a ''div'' element we do like > this, which works fine.. > link_to_remote(:update => ''updatediv'', > :url => { :action => :my_method }) > > But i want to update the output which is an ''Image'' in my case into a > HTML IMG tag and display it in the browser. I want to go only for <img> > tag.. > > Thank You > DineshShould be simple enough. You want to use RJS. First remove the :update part of the link_to_remote. Then create a view file for your action except call it my_method.rjs instead of my_method.rhtml. Now put something like this in my_method.rjs: page[''id_of_my_image_element''].src = @image.method_that_returns_src And you should be set. -- Posted via http://www.ruby-forum.com/.