On checking the CheckAll
check box I am checking all the checkboxes on a page and moving the parent, which is a table, of each of those checked boxes into another div. And On Unchecking the CheckAll
check box I have to uncheck all the checked checkboxes on the page and remove the copied table elements from the div.
/*******************Check and Uncheck all the checkboxes on the page***********************************/
$("#dvReports #checkAll").click(function ()
{
var pageNum = $("#dtlRptPrvNxtLnk .selected.link_look").html();
alert(pageNum);
if ($("#dvReports #checkAll").is(':checked'))
{
$("#dvReports input[type=checkbox]").each(function ()
{
$(this).prop("checked", true);
// If a listing is selected then move it to divPrintContainer,
// which is buried inside _reportLayout.cshtml
$(this).closest('table')
.toggleClass(pageNum)
.clone()
.appendTo("#divPrintContainer");
});
}
else
{
$("#dvReports input[type=checkbox]").each(function ()
{
$(this).prop("checked", false);
});
$("#divPrintContainer").children('table.'+ pageNum ).remove();
}
});
I am running into the following issue :
- For every even number of clicks on the
CheckAll
checkbox the.toggleClass(pageNum)
is not working. i.e. The first time I check the Checkall.toggleClass(pageNum)
assigns the class name. Now I uncheck theCheckall
. And again I check the Checkall it won't assign the pagenum as class (but I do see the alert with the pageNum).