Answer the question
In order to leave comments, you need to log in
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 %>
Answer the question
In order to leave comments, you need to log in
the solution is not to duplicate the JS code, but to take it apart from the checkbox
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question