Can't launch other JS function from within Hype consistently

(Steve) #1

I can’t figure this out… I have a simple Hype Banner that has three Elements each with their own ID. Additionally the page is running a LayerSlider PopUp that is looking for a click on the IDs that are within the Hype document.

The problem is lack of consistency and not knowing how to debug on a greater level to see if it’s to do with loading sequence, DOM or ?

There is a test page here that shows the issue:

I added a simple Div that has one of the expected ids which works without issue. The Hype banner sometimes works on some of the videos other times not so I was thinking a loading sequence issue. But also FireFox and Chrome work differently (Firefox fails 100% in testing on my Mac).

Viewing the Console does not show anything specific to this issue so I am lost and thinking recoding the Hype Banner to do it’s own Lightbox popup, though in the past I was not able to successfully get that to work either :frowning:

What am I missing? (80.7 KB)


What might be happening is that the listener function is trying to listen for a click on an element which does not yet exist in the DOM. You probably need to run your function after the Hype document has loaded:

    function documentHasloaded(hypeDocument, element, event) {

        var lsjQuery = jQuery;
        lsjQuery(document).ready(function () {
            if (typeof lsjQuery.fn.layerSlider == "undefined") {
                if (window._layerSlider && window._layerSlider.showNotice) {
                    window._layerSlider.showNotice('layerslider_225', 'jquery');
            } else {
                    createdWith: '6.7.1',
                    sliderVersion: '6.7.6',
                    type: 'popup',
                    popupShowOnce: false,
                    popupShowOnClick: '#vid3',
                    plugins: ["popup"]


    if ("HYPE_eventListeners" in window === false) {
        window.HYPE_eventListeners = Array();
        "type": "HypeSceneLoad",
        "callback": documentHasloaded

It looks like you could combine each of your three functions in here as well since you are repeating a lot of code.

(Steve) #3

I’ll give that a try… Thanks for the tip and also idea of moving the functions within Hype.