• Hi guys!

    Why following code written in jquery works great

    <script>
        jQuery(document).ready( function($) {
            $(document).on('heartbeat-tick', function() {
                console.log('OK');
            });
        });
    </script>

    … but when I try to use it with vanilla js then it’s not working:

    <script>
        jQuery(document).ready( function($) {
               document.addEventListener('heartbeat-tick', function() {
                     console.log('OK');
               });
        });
    </script>
Viewing 1 replies (of 1 total)
  • It’s likely because of the extra data and handling that jQuery events have that plain ones don’t.

Viewing 1 replies (of 1 total)
  • The topic ‘Heartbeat API in Vanilla JS (addEventListener)’ is closed to new replies.