Calling a method right after the "init" event causes an error
See original GitHub issueI 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
Issue Analytics
- State:
- Created 8 years ago
- Reactions:16
- Comments:12
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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/
This looks good: https://jsfiddle.net/fypoz9eu/10/
Perhaps because the OP loaded the missing JS? http://kamara.fi/x/jenni/resources/plugins/slick/slick.min.js
at: https://jsfiddle.net/fypoz9eu/5/