Notifications

Notifications are important when interaction with users. Simcify comes with two open source notification libraries.

1.) SweetAlert

Sweetalert is an open source notifications library we love, Simcify comes with sweetalert version 2. You can checkout it's documentation here.

You can always use the sweetalert code from their documentation but we have simplified to for a quicker way to use it with Simcify. Check this out;

notify(title, message, type, button, advanced);

arguments

Parameter

Required

Type

Description

title

Yes

string

Title of the notification.

message

No

string

Message to display.

type

No

string

warning | success | info | error (info is default).

button

No

string

Label of confirm button, default is okay.

advanced

No

object

Advanced option as explained below.

advanced options

Need more options? see the options available on the advanced variable.

{
    showCancelButton: true,
    closeOnConfirm: true,
    callback: "reload()"
}

option

Type

Description

showCancelButton

boolean

Show the cancel option on the alert.

closeOnConfirm

boolean

wether to close the alert on confirm or not

callback

string

A function to be called after confirmation.

Hide sweelAlert

To hide any open sweetAlert;

swal.close();

2.) Toastr

toastr is another powerful notification library that comes with simcify. We didn't modify it really just initialised it. here are example usage;

// success
toastr.success("Changes successfully saved.", "Successful!");

// error
toastr.error("Invalid input.", "Oops!");

// warning
toastr.success("This ation can't be undone.", "Warning!");

// info
toastr.info("This is the latest version.", "Head up!");

Additional options

By default the toastr notifications will timeout and disappear without a close button. You can add a close button or disable the timeout this way:

toastr.error("Email does not exists.", "Oops!", {timeOut: null, closeButton: true});

Hide Toastr

to hide toastr

toastr.clear();

Last updated