question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling a method right after the "init" event causes an error

See original GitHub issue

I just spent some hours wondering why I couldn’t call any slick functions. I had my code written up like this:

$slider.on("init", function() {
    // a hack to solve a conflict between plugins, not important
    $slider.find("[data-slick-index='-1'] img").addClass("lazyload");
    $slider.slick("slickGoTo", 1, true);
}

$slider.slick();

Unfortunately this didn’t work. It seems that slick calls the init event before the methods are ready to be called. But it doesn’t have any event that fires once it’s completely loaded. The error I got was:

Cannot read property "slickGoTo" of undefined

http://jsfiddle.net/fypoz9eu/5/

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:16
  • Comments:12

github_iconTop GitHub Comments

14reactions
gavinlynchcommented, Apr 10, 2017

anyone still dealing with this: I seemed to have some success with wrapping my API call in a setTimeout(method, 0). Bummer of a bug.

https://jsfiddle.net/m4an6mzo/

5reactions
gausartscommented, Jan 10, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to run a function right after the __init__ of a class?
A decorator might be an overkill here. You can just call the method in __init__ : class SomeClass(commands.Cog): def __init__(self, ...
Read more >
'init' event not always firing on Lightning component used as ...
Our observations so far suggest that the event WILL be fired when the component is actually created (just like the documentation says), but...
Read more >
Error : "cannot call methods on ... prior to initialization" due to ...
As the page loads, the onchange event is triggered BEFORE the document.ready function executes. I don't know why, but it does. This causes...
Read more >
Initialization, Finalization, and Threads — Python 3.11.1 ...
The following functions can be safely called before Python is initialized: ... this may cause destructors ( __del__() methods) to fail when they...
Read more >
Classes - Object-Oriented Programming in Python
When we call the class object, a new instance of the class is created, and the __init__ method on this new object is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found