title: Limit number of checkboxes allowed to be selected in a Datatable in javascript (Ruby on Rails)
body: <p>i have a Data table that has a  column that allows the user to select multiple records in the datatable.</p>
  
  <p><a href="https://i.stack.imgur.com/rGRMs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rGRMs.png" alt="enter image description here"></a></p>
  
  <p>The problem is i want them to only be able to select 1 record from this datatable.</p>
  
  <p>The ideal solution would be to limit the selects to 1 record and every time they select another record it removes the check from the last record selected. I would like to know how i can achieve this using javascript. Thanks</p>
  
  <p>EDIT -this is my table </p>
  
  <pre><code>`$('#email_templates').DataTable({
        pageLength: 25,
        responsive: true,
        processing: true,
        serverSide: true,
        autoWidth: false,
        ajax: $('#email_templates').data('source'),
        dom: '&lt;"html5buttons"B&gt;lTfgitp',
        buttons: [
        { extend: 'copy'},
        {extend: 'csv'},
        {extend: 'excel', title: 'Email Templates'},
        {extend: 'pdf', title: 'Email Templates'},
        {extend: 'print',
        customize: function (win){
          $(win.document.body).addClass('white-bg');
          $(win.document.body).css('font-size', '10px');
  
          $(win.document.body).find('table')
          .addClass('compact')
          .css('font-size', 'inherit');
        }
      }
      ],
      columnDefs: [
      {
        orderable: false,
        targets: [0,1]
  
      },
      {
       'targets': 0,
       'searchable': false,
       'orderable': false,
       'className': 'dt-body-center',
       render: function (data, type, full, meta){
         return '&lt;input type="checkbox" class="checkbox" name="id[]" value="' + $('&lt;div/&gt;').text(data).html() + '"&gt;';
       }
     }
     ],
     columns: [
     { width: "20%" },
     { width: "40%" },
     { width: "40%" }
     ]
   });
  
    });`
  </code></pre>