Changing link_to (with :method => :put) in ajax version

Im wondering if someone of you have resolved this problem.

If you are using JQuery,
and you want to replace the onclick event of link generated (with
link_to) with a ajax call (PUT)

How should you make it ?

This is the link I would change :

<%=link_to ‘I like it’, ilike_post_path(post), :class => ‘put’, :method
=> :put %>

this is the application.js

$(‘a.put’)({

this.unbind(‘click’, false);
this.click(function() {
$.put($(this).attr(“href”), …, null, “script”);
return false;
})

and this is the problem I have met:
when I click in the url the browser performs TWO http calls:
-one with Mime format = text/html”
-and one with Mime format = text/javascript”

In practice “this.unbind(‘click’, false)” doesn’t works !
I could use “this.removeAttr(’onclick’)” but I don’t think this is a
fine way to resolve it.

I hope my explanation was clear :slight_smile:

Have someone else met this problem ?

thank you,
Alessandro