Hello,
I'm facing a problem while checking a checkbox in dynamically created table.
I'm using wicket framework in frontend which creates a dynamic table to hold the files. Each file has provided checkbox for selection and deselection. I have requirement to check a file say 111001A.CR up on checking of 111001A.CN (Name of files are same, just extension varies).
For selection and deselection of files, i'm using following jQuery Code:
function selectDeselectMatchingFiles(){
$(".dataview tr").next().find(':checkbox').click(function(){
var selectedFileCheckState = $(this).attr('checked');
var selectedFile = ($(this)).parent().parent().find('td').find('span').text();
var selectedFileName = selectedFile.substring(0,selectedFile.indexOf("."));
$(".dataview tr").next().find(':checkbox').each(function()
{
var matchingFile = ($(this)).parent().parent().find('td').find('span').text();
var matchingFileName = matchingFile.substring(0,matchingFile.indexOf("."));
if(selectedFileName==matchingFileName && selectedFileCheckState){
$(this).attr("checked",true);
}else if(selectedFileName==matchingFileName && !selectedFileCheckState){
$(this).attr("checked",false);
}
});
});
}
Above logic is not working (clik event is not fired) when I clicke any ckeckbox "First Time". After this for subsequent clickes, the logic is working fine and i'm able to check the file say 111001A.CD on selection of 111001A.CR.
Can any body assist me why click event on the checkbox is not firiing first time? Have I did some thing wron in jQuery?