通过rails中的ajax渲染Link_to_remote

时间:2022-05-21 20:18:03

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.

我正在使用rails 2.我想创建一个link_to_remote对象并在html页面上呈现它。我想通过ajax发送日期。我正在尝试这个。

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.

请帮助我。

1 个解决方案

#1


1  

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

在这种情况下,您不需要<%=%>标记 - 它们用于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'}  }"

#1


1  

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

在这种情况下,您不需要<%=%>标记 - 它们用于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'}  }"