0

I have a function where if the user clicks on the pagination links of a dynatable (page numbers, Previous, Next) that it will disable a couple of the fields from updates based on a certain status. here is the function call:

  $(document).on('click', '.dynatable-page-link', function() 
      {

             var statusCheck = $('#UpdCMDStatus').val();
             alert ("Enter the function on dynatable page link")  ;

             if (statusCheck === "CP" || statusCheck === "VP")
             {
                $('table#checkedTable input[type=checkbox]').attr('disabled','true');
                $('table#checkedTable input[type=text]').attr('disabled','true');
                $('table#checkedTable select[id^=Modify]').attr('disabled','true');

             }  
             else
             {
                $('table#checkedTable input[type=checkbox]').removeAttr("disabled");

             }

          });

I know that the processing is working when I load the page because it is disabled the 3 fields. I know from looking at the alert box that I am accessing the function at the right time. But it doesn't look like the input or select boxes are being disabled when just clicking. I tried to do a debug on document.getElementById("checkedTable").rows[1].cells[1] (a check box field) and attributes were showing disabled = false. Guess what is confusing why it working on the page load but not in a function tied to pagination.

Thanks again.

hammerva
  • 129
  • 1
  • 14

1 Answers1

1

You are passing a string value instead of bool in your attr function which should actually be a prop function.

Here are the 2 fixes.

  1. Using .attr()
$('table#checkedTable input[type=checkbox]').attr('disabled','disabled');    
$('table#checkedTable input[type=text]').attr('disabled','disabled');    
$('table#checkedTable select[id^=Modify]').attr('disabled','disabled');

$('table#checkedTable input[type=checkbox]').removeAttr("disabled");
  1. Using .prop()
 $('table#checkedTable input[type=checkbox]').prop('disabled',true);
    $('table#checkedTable input[type=text]').prop('disabled',true);    
        $('table#checkedTable select[id^=Modify]').prop('disabled',true);

$('table#checkedTable input[type=checkbox]').prop("disabled",false);
DinoMyte
  • 8,737
  • 1
  • 19
  • 26
  • Although I probably needed to do the attribute/prop that way, it wasn't causing the problem. I have to figure out the path of dynatables because whatever I do in the click function is wiped out. Thanks – hammerva Jun 07 '16 at 11:47