Topic: Double Click with rails

Hello,

I don't know how to implement double click (like ondblclick on javascript) with Ruby on Rails.

I have this code:

<%= link_to_remote (image_tag("/images/close_folder_list2_h.png")),{:url => {:controller => "projects", :action => "expand_list",:id_list => list.id.to_s},:update => @update_List} %>

I only need it to work  when I click twice on the link


Does someone know how I can do this with Rails?


Thanks

Last edited by urisv30 (2011-03-14 18:08:38)

Re: Double Click with rails

well that's rails 2 syntax, and you don't use ruby to detect double click, only javascript. With jQuery I'd do something like this:

[first give the image an HTML ID]

$('#some_img_id').dblclick(function(){
  $.ajax({
    url: "/projects/expand_list",
    success: function(){
      alert('done');
    }
  });
});

... something like that

Now this assumes you're using jQuery, which means you have to configure your app to use jQuery.

Secondly, for the ajax syntax in jQuery see documentation

Last edited by RailsRhino (2011-03-14 18:15:30)

- Ben