从嵌入的ruby标记调用javascript

时间:2011-08-30 09:10:07

标签: javascript ruby-on-rails-3

星期二早上很容易...... 我试图从这个ruby标签中调用一个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 个答案:

答案 0 :(得分:1)

您可以使用javascript_tag

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