Selecting correct radio button using jQuery

Selecting correct radio button using jQuery

I have 4 radio buttons and a data table that has a row that matches each radio button value. When I select a data table row the corresponding radio button is selected. I can cycle through all data table rows and watch each corresponding radio button get selected. If I select a data table row that has the same radio button value of a previously selected row or go back and re-select a row, the radio buttons stop being selected. Can someone tell/show me why my radio buttons are not being selected the 2nd time through?

  1. $('#reviewerDatatable tbody').on('click', 'tr', function () {
        var rowData = table.row(this).data();
  2.     $.each(rowData, function (name, val) {
            var $el = $('[name="' + name + '"]'),
                type = $el.attr('type');
  3.         switch (type) {
              case 'radio':
  4.                 console.log(val);
                    $el.filter('[value=' + val + ']').attr('checked', true);
                    break;
  5.             case 'date':
                    var now = new Date(val);
                    var day = ("0" + now.getDate()).slice(-2);
                    var month = ("0" + (now.getMonth() + 1)).slice(-2);
                    var formattedDate = now.getFullYear() + "-" + (month) + "-" + (day);
                    $el.val(formattedDate);
                    break;
  6.             default:
                    $el.val(val);
            }
        });
    });