Skip to content

Position of toastr container on page and preventDuplicates option #419

@marianacapelo

Description

@marianacapelo

I'm currently struggling to control the position of toastr container on page.
The container element is inserted on the page by me but is destroyed after the first notification and I can't give the style I want on the second (auto generated) container element appended to the body.

I found that if I added an empty span to the container, the element is not destroyed, but with preventDuplicates option set to true, it does not work well:

           function removeToast($toastElement) {
                if (!$container) { $container = getContainer(); }
                if ($toastElement.is(':visible')) {
                    return;
                }
                $toastElement.remove();
                $toastElement = null;
                if ($container.children().length === 0) {
                    $container.remove();
                    previousToast = undefined;
                }
            }

And so the previousToast is not unset (as it should).
The result is - when a message is displayed and closed, and a new and equal one is created, it is not displayed (because previousToast was not unset and so toastr thinks the first one is still being displayed).

I couldn't find any other solution to this specific problem, and I believe that it would be really simple to add an option to control the remove action (true/false) of the container element so that everything would work smoothly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions