The following works fine. I click #testlink and it fires.
jQuery(document).ready(function() {
jQuery("#testlink").on("click", function(event) {
document.dispatchEvent(new CustomEvent('funcTest', {
'detail': {
test: 'stuff'
}
}));
});
});
Now I want to do the same thing without an on.click, I want it to fire when the web page loads. So remove the onclick.
jQuery(document).ready(function() {
document.dispatchEvent(new CustomEvent('funcTest', {
'detail': {
test: 'stuff'
}
}));
});
But it doesn't work. Nothing happens. Why? How can I get this to fire when the page loads?