Maksims
Maksims

Reputation: 167

Toastr "options" don't work

I create notification message using Toastr. My notification message is shows, but I can't use any options, I put some options but they don't work.

$('#editButton').click(function() {
  toastr.success('System successfully saved');
  toastr.options.timeOut = 5000;
  toastr.options.positionClass = toast - top - center;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">

<button class="button" id="editButton" type="submit" aria-hidden="true">Edit</button>

Upvotes: 2

Views: 6565

Answers (2)

jbe
jbe

Reputation: 1782

toastr.options.positionClass = toast-top-center;

You forgot the quotes.

toastr.options.positionClass = "toast-top-center";

Upvotes: 0

JamesT
JamesT

Reputation: 3028

The toast displays when you call success(). So you need to set your options before that.

Also toast-top-center is not a javascript identifier, it needs to be in quotes.

$('#editButton').click(function () {
    toastr.options.timeOut = 5000;
    toastr.options.positionClass = 'toast-top-center';
    toastr.success('System successfully saved');
});

Upvotes: 5

Related Questions