Skip to content

If you don't want to hide the toast as an important message... #616

@Ramonbc95

Description

@Ramonbc95

·Hi i have an idea to get controlled the exception when we try to get a not hide toast when hideMethod is named with any value. On this case i'm talking to customize the call as if we put:

//CODE
toastr.warning("You should activate your cookies to get a better expieriences and to make possible work fine this website", "Warning",{ hideMethod: "" });

·With this should be fixed the toast, but javascript is throwing an exception because says "$toastElement[method] is not a function", but i have an idea for that, because if we check on line 413 if we have the variable 'method' is empty like "", we can keep the toast with no exceptions. Like this:

//CODE
function hideToast(override) {
                    var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
                    var duration = override && options.closeDuration !== false ?
                        options.closeDuration : options.hideDuration;
                    var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
                    if ($(':focus', $toastElement).length && !override) {
                        return;
                    }
                    clearTimeout(progressBar.intervalId);
                   /*--------------HERE is my line code-------------*/
                    if(method !== ""){
                    return $toastElement[method]({
                        duration: duration,
                        easing: easing,
                        complete: function () {
                            removeToast($toastElement);
                            clearTimeout(intervalId);
                            if (options.onHidden && response.state !== 'hidden') {
                                options.onHidden();
                            }
                            response.state = 'hidden';
                            response.endTime = new Date();
                            publish(response);
                        }
                    });
                }
                }

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