admin管理员组文章数量:1406951
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=".1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="//cdnjs.cloudflare/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<button class="button" id="editButton" type="submit" aria-hidden="true">Edit</button>
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./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare./ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="//cdnjs.cloudflare./ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<button class="button" id="editButton" type="submit" aria-hidden="true">Edit</button>
Share
edited May 22, 2017 at 15:05
jbe
1,8021 gold badge13 silver badges20 bronze badges
asked May 22, 2017 at 10:01
MaksimsMaksims
1672 silver badges11 bronze badges
2 Answers
Reset to default 5The 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');
});
toastr.options.positionClass = toast-top-center;
You forgot the quotes.
toastr.options.positionClass = "toast-top-center";
本文标签: javascriptToastr quotoptionsquot don39t workStack Overflow
版权声明:本文标题:javascript - Toastr "options" don't work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744911571a2631949.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论