lundi 20 avril 2015

Checkbox callback function not getting called from second onchange

I am creating a table dynamically in the run time based on some action in UI as follows

     $(figure.children.data).each(function (i, Column) {
            if (i != 0) {
                var callBack = function () {
                    RemoveColumn(figure, Column.figure.id);
                }

                var input = $("<input>")
                            .attr("type", "checkbox")
                            .attr("checked", "checked")
                            .on("change", callBack);

                var tr = $('#tblEntity').append('<tr>');

                $("<td>").appendTo(tr).append(input);

                $("<td>").appendTo(tr).append(Column.figure.text);
            }
 });

and the RemoveColumn function is as follows.

function RemoveColumn(figureToBeModified,columnID) {    
    $(figureToBeModified.children.data).each(function (i, column) {
        if (column.figure.id == columnID) {
            figureToBeModified.hide(column.figure);

            figureToBeModified.remove(column.figure);
        }
    });
}

Problem: When i un check the check box for the first time it is working fine(means RemoveColumn function is getting called),but afterwords if i check or un check the checkbox RemoveColumn is not getting called.




Aucun commentaire:

Enregistrer un commentaire