lundi 21 mai 2018

jQuery datatable: Enable a few textboxes on each of the pagination

I have created a datatable in which one of my column has a checkbox element and other column has a textbox element. The ID's for each of these are generated dynamically based on what data in the rows are populated.

What I have been trying to do with this is enable the textbox when a corresponding checkbox is checked. This datatable has pagination.

Issue:

Using the code below I am able to enable the textbox when the checkbox is checked on a certain page (page 1 for example). However, when I try to enable the textbox on page 2 after a few of the texboxes are enabled on page 1, it doesn't allow me to do so. What am I doing wrong ?

table.$("input:checkbox", { "page": "all"}).change(function () {
   var someObj = {};
   someObj.Checked = [];

   table.$("input:checkbox", { "page": "all" }).each(function () {
      if ($(this).is(":checked")) {
            someObj.Checked.push($(this).attr("id"));
            document.getElementById("ID_" + $(this).attr("id")).disabled = false;
      }
   });

   //console.log(someObj.Checked);
});




Aucun commentaire:

Enregistrer un commentaire