kasperlegarth/instastory.js

DOM element

elemis opened this issue · 1 comments

Just noticed a warning that says:
The DOM element you tried to initiate the plugin on, does not exist
This happens if there are more than one scripts for different feeds but only one of them (or none) is called on a page. How to initiate the script only if the element is present?
Link for demonstration: http://themes.iki-bir.com/inst/

Hi @elemis
That is actually a safe shift. If the DOM element isn't there it stops the rest of the script to be executed, and in that way, it never gets initiated for that DOM element. I have on my todo to include a boolean if you want ket debugging logged to the console.

For now, you could just make the check your self before trying to initiate the plugin:
if($('#demo1').length > 0) {
$('#demo1').instastory({
...
});
}