Bilal Ahmed
Bilal Ahmed

Reputation: 433

Render Link_to_remote via ajax in rails

I am working in rails 2. I want to make an link_to_remote object and render it on html page. I want to send date via ajax. I am trying this.

render :text => "<font color='"+ color +"'>" +params[:ajax_status] + "</font>" + <%= link_to_remote '| Undo',
              :update => 'status_'" +params[:ajax_status]+ ",:url => {:controller => 'requests', :action => 'action_on_punching_request', :id => "+ params[:id] +" :ajax_status => 'Undo'} %>

But unable to proceed. It shows on webpage

Accepted<%= link_to_remote '| Undo', :update => 'status_'Accepted,:url => {:controller => 'requests', :action => 'action_on_punching_request', :id => 20 :ajax_status => 'Undo'} %>

PLease help me out.

Upvotes: 1

Views: 138

Answers (1)

Brad Werth
Brad Werth

Reputation: 17647

You don't need the <%= %> tags, in this case - they're for erb.

Try just:

render :text => "#{ content_tag :font, params[:ajax_status], :color => color }#{  link_to_remote '| Undo', :update => "status_#{ params[:ajax_status] }", :url => {:controller => 'requests', :action => 'action_on_punching_request', :id => params[:id], :ajax_status => 'Undo'}  }"

Upvotes: 1

Related Questions