0

Easy one for Tuesday morning... Im trying to call a javascript function from inside this ruby tag...

<% @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 %>

Where the question marks are i want to call a javascript function. But how do i do that?

1 Answer 1

1

You can use javascript_tag:

<%= javascript_tag  do -%>
  alert('All is good')
<% end -%>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.