jRails problem

Hi,

I am developing a Rails app and now I want to try some Ajax
funcionality. I have a tracks list, and each track has a delete button.
I have this operation implemented without Ajax with a redirection, and
now I want to do it with Ajax. I am using JQuery and jRails.

Here is my code:

This is the delete function in my controller:

def delete_track
@track_id = params[:track_id]
Track.delete(@track_id)
respond_to do |format|
format.html {redirect_to :action => ‘index’}
format.js
end

This is my html where the tracks list is:

Estado de su unidad musical:

    <%unless @musical_unit.nil? %> <% for track in @musical_unit.tracks %>
  1. <%= track.name %> de <%= track.album.singer.name %> <%= link_to_remote(image_tag("delete.png", :alt => 'Borrar', :size => "16x16", :title => "Borrar " + track.name + " de mi unidad musical"), :update => "musicalUnitTile", :url => {:controller => "tracks", :action => 'delete_track', :track_id => track.id}) %>
  2. <% end %> <% end %>

And this is my RJS code:

page[’#track’ + @track_id].hide

I want to hide the li element of the track after deleting it from the
db.

In my application.js I have this:

jQuery.ajaxSetup({
‘beforeSend’: function(xhr){xhr.setRequestHeader(‘Accept’,
‘text/javascript’)}
})

The problem is that after executing the delete action, the RJS code is
called, but it is not interpreted. The page prints the RJS as if it was
html code in the musicalUnitTile div, and I want to execute the RJS
code as Javascript.

What am I doing wrong?

Thanks!