CodeSeven / toastr

Simple javascript toast notifications
http://www.toastrjs.com
MIT License
11.96k stars 2.04k forks source link

Custom options are not being respected #619

Open JayBox325 opened 5 years ago

JayBox325 commented 5 years ago

I have set up notifications on my project using Toastr, however, my custom options aren't being respected.

Below is my JavaScript where I have imported Toastr, set the config inside the toastr.options object as per the documentation, yet my options are not being used at all. I have commented out the TypeBasedOverrides for now in just trying to get the options working.

Any idea where I'm going wrong in getting them implemented? At the moment, both the test notifications are fading out automatically 4 seconds in.

 import * as toastr from 'toastr'

export default function notifications($) {
    const $window = $(window)

    // Config
    toastr.options = {
        "preventDuplicates": true,
        "closeButton": true,
        "extendedTimeOut": "0",
        "timeOut": "0",
        "showMethod": "slideDown"
        // "typeBasedOverrides": {
        //     "info": {
        //         "timeOut": "10000"
        //     },
        //     "success": {},
        //     "warning": {
        //         "timeOut": "0"
        //     },
        //     "error": {}
        // }
    }

    if ($window.width() > 900) {
        toastr.info('This is a notification', 'Notification with a title')
        toastr.warning(`
            <a href="#" target="_blank" rel="noopener noreferrer">Title</a>
        `, 'Message')
    }
}