使用coffescript设置所有复选框的值

时间:2016-06-06 07:15:07

标签: ruby-on-rails coffeescript

如果当前复选框选中为true,我如何更改其他人的值复选框'已选中'为'false'?

我用于复选框库jquery-labelauty

项目/ _responses.html.erb

<% @project.responses.each do |response| %>   
    ..........................................
    <div class="controls">
     <%= check_box_tag '', true, false, { class: "control__check" } %>  
    </div>
    ..............................................
  <% end %>

projects.js.coffeescript

$(document).on 'ready page:load', ->
  $('#project_skill_list').tagit 
    allowSpaces:true,
    tagLimit: 15

  $('.control__check').labelauty
    checked_label: "Cancel",
    unchecked_label: "Select",
    force_random_id: true

  $('.control__check labelauty').change ->
    checkboxes = $(this).siblings()
    if ($(this).prop("checked"))
      checkboxes.prop('checked', false)  

如果我单击一个复选框,则没有任何反应。我如何解决问题?

0 个答案:

没有答案
相关问题