N
N
Nazar Jeveling2014-08-07 10:47:25
JavaScript
Nazar Jeveling, 2014-08-07 10:47:25

Where is the problem in JavaScript?

I have a checkbox in one Rails application, and there is javaScript that processes clicks by calling a method in the controller, I can have many checkboxes on one page, they are generated like this:

<% Project.each do |project| %>
  <% project.tasks.each do |task| %>
    <%= check_box_tag 'status', 'complete', task.status, data: { id: tasl.id } %>
    <script>
      $('#status').change(function() {
        $.get('/task/' + $(this).data('id') + '/task_status' )
      });  
  <% end %>
<% end %>

and the problem is that this script works only on the first checkbox, on the next even the log is silent. What could it be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Jeveling, 2014-08-07
@xo8bit

the solution is not to duplicate the JS code, but to take it apart from the checkbox

A
Andrew Emelianenko, 2014-08-08
@YourWest

Ummm... Not a closed script tag?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question