Hi so I'm dynamically creating a checkbox list with children using JavaScript in the Body of the html page, that runs in electron.
But my jQuery code that checks the parent tree items that I got from here works fine only when I add the debugger; after the $(window).on('load', function (e) { line
jQuery code:
<script>
$(window).on('load', function (e) {
$('input[type=checkbox]').click(function(){
if(this.checked){
$(this).parents('li').children('input[type=checkbox]').prop('checked',true);
}
$(this).parent().find('input[type=checkbox]').prop('checked',this.checked);
});
});
</script>
example Javascript code to create the list:
document.getElementById('list').innerHTML='<ul id="file" class="tree"></ul>';
scan.filesscan('tests', files => {
files.forEach(function(file, j) {
suites = pr.parseFile('tests',file, suite =>{
document.getElementById('file').innerHTML+='<li><input type="checkbox" id="' + j +'" name="files" value="' + file + '">' + file + '<ul id="'+file+'" class="tree"></ul></li>';
document.getElementById(file).innerHTML+='<li><input type="checkbox" id="' + j + '" name="suite" value="' + suite.name + '">' + suite.name + '<ul id="'+suite.name+'"></ul></li>';
for (let i = 0; i < suite.tests.length; i++) {
document.getElementById(suite.name).innerHTML+='<li><input type="checkbox" id="' + j + '" name="'+suite.name+'" value="' + suite.tests[i] + '">' + suite.tests[i] + '</li>';
}
});
});
});
As stated the code works fine but only when I have the debugger; line in after window.on load this is obviously a timing issue how would I resolve this?