You've got two mistakes there. First off you would want to trap the "change" event so you get it after it has... well, changed. "input" might be a better event though.
Second you're trapping the label, not the input. The input is what changes, not the label.
And really you don't need the variable for this either.
onst addSelectAll = (element) => {
element.__make(
"label",
{ placement : "afterbegin" },
[ "input",
{
className : "switch",
type : "checkbox",
onchange : (e) => {
console.log(e.currentTarget.checked);
}
}
],
["ins", { hidden : true } ],
["span", "Select All"]
);
}
normally I say don't use the "on" attributes, but when you assign it here you're not making it reliant on a global function, and you literally just created the element so you're not overwriting other events.