1

Sometimes my event listeners work and the elements trigger the events, other times they do not. I believe it is due to a delay. However chrome states the page is fully loaded by the time. I'm clicking on elements. It is a matter of seconds, not milliseconds.

require(['jquery'],function($){
   $(window).load(function() {
       // Added event listeners here.
   });
});

Has anyone else encountered this?

1

1 Answer 1

1

I faced the same problem. The solution worked for me after adding the js in function and calling that function.

function test() {
    require(['jquery'], function ($) {
        $(window).load(function () {
            // Added event listeners here.
        });
    });
}

For example if you are using the Carousel. I created the delay of one second then I don't face this issue.

function slider() {
    require(['jquery', 'jquery/ui'], function ($) {

        $(document).ready(function () {

            $("#banner_slider").owlCarousel({
                navigation: false,
                slideSpeed: 300,
                paginationSpeed: 400,
                singleItem: true,
                pagination: true,
                rewindSpeed: 500
            });
            window.clearTimeout();
        });
    });
}
setTimeout(slider, 1000);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.