apvarun / toastify-js

Pure JavaScript library for better notification messages
https://apvarun.github.io/toastify-js/
MIT License
2.13k stars 230 forks source link

Uncaught Root element is not defined #57

Closed ghost closed 4 years ago

ghost commented 4 years ago

adding selector as a css ID defined for a DOM element, throws error.

Toastify({
    text: message,
    duration: 5000,
    position: "center",
    selector: "main",
    className: `alert alert-info`,
  }).showToast();

And the HTML element it is supposed to be added to:

<main id="main"></main>

The error being thrown is:

Uncaught Root element is not defined

RDjarbeng commented 1 year ago

What was the solution for this error? I am currently facing the same issue. Even when I add

selector: '#main' as the id

EDIT: found a solution

For IDs just use the name. So if your element has id='main' use selector='main' instead of #main Couldn't find a solution for css classes though, guess that wouldn't make much sense since classes can be duplicates. Maybe the docs should say ids instead of 'CSS selectors' 😒