2011-08-30 50 views
0

輕鬆一星期二上午... 我試着從這個紅寶石標籤內調用javascript函數...從嵌入式紅寶石標籤調用JavaScript的

<% @efforts.each do |effort| %> 
      <% if effort.project_task.project.project_name == "ADMIN"%> 
      ?????????????? 
      <% else %> 
      <tr> 
       <td><%= effort.project_task.project.project_number %> <%= effort.project_task.project.project_name %> - 
        <%= effort.project_task.task_name %> 
       <td><%= text_field :effort, :hours, :name => 'effort_' + effort.project_task_id.to_s, :id => 'effort_' + effort.project_task_id.to_s, 
            :value => "%d" % (effort.hours.nil? ? 0 : effort.hours), :size => 20 %> 
       <td><%= link_to image_tag('icons/delete.png'), effort, :confirm => 'Are you sure?', :method => :delete %> 
      </tr> 
      <% end %> 
     <% end %> 

其中問號是我想打電話給一個javascript函數。但我該怎麼做?

回答

1

您可以使用javascript_tag

<%= javascript_tag do -%> 
    alert('All is good') 
<% end -%> 
+0

感謝這就是我想要的! – SD1990