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?

Qaisar Satti
32.6k18 gold badges88 silver badges138 bronze badges
asked Jul 21, 2016 at 8:16
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);
Siarhey Uchukhlebau
16.2k11 gold badges57 silver badges89 bronze badges
answered Jul 21, 2016 at 9:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.