jRails problem


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]
respond_to do |format|
format.html {redirect_to :action => ‘index’}

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

In my application.js I have this:

‘beforeSend’: function(xhr){xhr.setRequestHeader(‘Accept’,

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?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs