Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How multiple show toasts with various options? #565

Open
shahovkit opened this issue Mar 12, 2018 · 2 comments
Open

How multiple show toasts with various options? #565

shahovkit opened this issue Mar 12, 2018 · 2 comments

Comments

@shahovkit
Copy link

shahovkit commented Mar 12, 2018

I need show toast for error with option "positionClass": "toast-top-right", and need show toast for warning with option "positionClass": "toast-bottom-right", but both toasts use only one setting.

CodePen

toastr.options = {
    "closeButton": false,
    "debug": false,
    "newestOnTop": false,
    "progressBar": false,
    "positionClass": "toast-bottom-right",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};
toastr.error('error','error');

var supportToastr =  toastr;
var options = {
    "closeButton": false,
    "debug": false,
    "newestOnTop": true,
    "progressBar": false,
    "positionClass": "toast-top-right",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": 0,
    "extendedTimeOut": 0,
    "closeClass": 'toast-close',
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut",
    "tapToDismiss": false
};
supportToastr.warning('warning','warning',options);
@zverev78
Copy link

Duplicate of #438

@ssammut
Copy link

ssammut commented Feb 9, 2022

I think that there is an easy way to manage different positionClass by specifying the containerId in the toastr options. Example:

toastr.options = {
    "positionClass": "toast-top-right",
};

toastr.success("default toastr position");

toastr.info('custom toastr position', '',
     {
         positionClass: 'toast-bottom-full-width',
         containerId: "toast-container-notifications"
     }
 )

The only change necessary to make this work is CSS. You need to find all css styling for #toast-container and replace that with [id^='toast-container']. You only need to make sure that you always name the containers with toast-container*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants