0

I got my script and it works pretty well (as I planned), but only after complete document loading with all checkboxes. It looks like this: enter image description here You can see it disables other checkboxes in required column. But here's the thing. I need to use this script when I creating my entriesm and at first loading my page with this entries look like this: enter image description here And after adding new entries script already doesn't work. I think this is about AJAX page reloading, the script is doesn't react to AJAX and don't work as a result.

$(document).ready(function () {
$('.field-correct :checkbox').change(function() {
    var $check = $(this),
        $div = $check.parent();
    if ($check.prop('checked')) {
         $('[name~="choice"], [name$="correct"]').each(function() {
              if (!$(this).is(':checked')) {
              $(this).prop('disabled', true);
              }
              });
    } else {
         $('[name~="choice"], [name$="correct"]').each(function() {
              if (!$(this).is(':checked')) {
              $(this).prop('disabled', false);
              $(this).css('background-color', 'red');
              }
              });
    }
});
});

What should I do to make my script work with AJAX too? upd: here's html enter image description here

Paul
  • 71
  • 4

0 Answers0