Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

DOM element #10

Open
elemis opened this issue Nov 8, 2019 · 1 comment
Open

DOM element #10

elemis opened this issue Nov 8, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@elemis
Copy link
Contributor

elemis commented Nov 8, 2019

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/

@kasperlegarth
Copy link
Owner

kasperlegarth commented Nov 11, 2019

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({
...
});
}

@kasperlegarth kasperlegarth added the enhancement New feature or request label Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants