Description
On your code you replace window.onload by your functionnality, instead of adding your's to list of existing
I propose you to use this way
/**
* Replace all .switch-button
inputs with "Bootstrap-Switch-Button"
* Executes once page elements have rendered enabling script to be placed in <head>
/
if (typeof window !== 'undefined')
var func = function() {
document.querySelectorAll('input[type=checkbox][data-toggle="switchbutton"]').forEach(function(ele) {
ele.switchButton();
});
if (window.addEventListener) {
window.addEventListener('load', func());
} else {
window.attachEvent('onload', func());
}
/
window.onload = function() {
document.querySelectorAll('input[type=checkbox][data-toggle="switchbutton"]').forEach(function(ele) {
ele.switchButton();
});
*/
};
Thank's