In one of my view , I have an image the user need to click to close a <div>selections</div> added by an Ajax call. if I use : <img src ="/images/icon_closeitem.gif", size="16*16", border="0",alt="Close Selection", title="Close", onclick="<%= remote_function(:url => { :controller => ''property'', :action => ''closeSelection'', :id => @property }) %>" > then it''s ok, in my property_controller.rn def closeSelection render :update do |page| page.replace_html ''selections'', "" end end will reset the content of the ''selections'' div to empty... fine but if I try to use <%= link_to_remote (image_tag("icon_edititem.gif" , :size=>"16*16", :border=>0, :alt=>"Edit this Property", :Title=>"Edit this Property") " , { :controller => "property", :action => "delete",:id => @property }, :class => "additem") %> the href is "#" (the onclikc seems to be generated..) the URL is ''property/#'' and obviously the controller action is not performed.... I surely miss an important parameter... which one ? kad -- Posted via http://www.ruby-forum.com/.
Hi Kad, please try: :url => { :controller => "property", :action => "delete",:id => @property } Cheers, Jan On 8/4/06, Kad Kerforn <kadoudal@wanadoo.fr> wrote:> > In one of my view , I have an image the user need to click to close a > <div>selections</div> added by an Ajax call. > > if I use : > <img src ="/images/icon_closeitem.gif", size="16*16", > border="0",alt="Close Selection", title="Close", onclick="<%> remote_function(:url => { :controller => ''property'', :action => > ''closeSelection'', :id => @property }) %>" > > > then it''s ok, in my property_controller.rn > def closeSelection > render :update do |page| > page.replace_html ''selections'', "" > end > end > > will reset the content of the ''selections'' div to empty... fine > > but if I try to use > <%= link_to_remote (image_tag("icon_edititem.gif" , :size=>"16*16", > :border=>0, :alt=>"Edit this Property", :Title=>"Edit this Property") " > , { :controller => "property", :action => "delete",:id => @property }, > :class => "additem") %> > > the href is "#" (the onclikc seems to be generated..) the URL is > ''property/#'' and obviously the controller action is not performed.... > > I surely miss an important parameter... which one ? > > kad > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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/20060804/ece0edd3/attachment.html
Jan Prill wrote:> Hi Kad, > > please try: > > :url => { :controller => "property", :action => "delete",:id => > @property } > > Cheers, > JanWhile this is the correct response, I must say that AJAX is way overkill for this. This task is just simply javascript. You are makign a request to the server that doesn''t change the server state in any way and return no useful information. I think this would be a much better solution: <%= link_to_function image_tag(...), render(:update) {|page| page.replace_html ''selections'', ""} %> Still uses RJS, and requires no AJAX call to the sever at all. Plus it will be insatnt rather than a short wait for the server to respond. Why query the server if you don''t need to? -- Posted via http://www.ruby-forum.com/.
Hi Alex, you''re absolutely right. I haven''t even took a closer look to what Kad is doing exactly but just saw that his typo. Cheers, Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060804/7f001b42/attachment.html