I want to add an onclick option to link_to method for loading an modal dialog box…i am using rails version 2.3.8 and i searched on google and could not do it. Plz anybody help me?
My link_to method as follows.
<%= link_to 'All countries',{:controller=>'countries', :action=>'new'}, :remote => true %>
If you are using 2.3.8, you don’t have :remote => true. You need to use link_to_remote if you are try to do an ajax action.
So it would look something like:
and your new method would have to handle the ajax request with something like
countries_controller.rb
UPDATED
If you want the onclick in addition to the ajax action, you can just pass it into the html options: