我想改变位置类为div点击我的烤面包。更改位置类toastr通知
positionclass:不会更改为Bottom。我在这里错过了什么?
以及如何使用
toastr.optionsOverride = 'positionclass:烤面包-底全宽度';
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<head>
<title></title>
<script type ="text/javascript" src ="@Url.Content("~/Scripts/jquery-1.6.4.js")"></script>
<script type ="text/javascript" src ="@Url.Content("~/Scripts/toastr.js")"></script>
<link rel="stylesheet" type="text/css" href="~/content/toastr.css" />
</head>
<script type="text/javascript">
$(document).ready(function() {
// show when page load
toastr.info('Page Loaded!');
$('#linkButton').click(function() {
toastr.optionsOverride = 'positionclass:toast-bottom-full-width';
// show when the button is clicked
toastr.success('Click Button', 'ButtonClick', 'positionclass:toast-bottom-full-width');
});
});
</script>
<body>
<div id ="linkButton" > click here</div>
</body>
更新1
调试我注意到,下面getOptions方法从toastr.js被重写 'positionclass:烤面包-底全宽' 之后为“烤面包机顶 - 右”
function getOptions() {
return $.extend({}, defaults, toastr.options);
}
更新2林e toastr.js中的140不是成功延伸m optionsOverride进入选项。
if (typeof (map.optionsOverride) !== 'undefined') {
options = $.extend(options, map.optionsOverride);
iconClass = map.optionsOverride.iconClass || iconClass;
}
更新3 当前位置问题已得到修复,但我不得不提到为低于3位置级别倍。我相信有一个不太嘈杂的方式来实现这一点。
$('#linkButton').click(function() {
toastr.optionsOverride = 'positionclass = "toast-bottom-full-width"';
toastr.options.positionClass = 'toast-bottom-full-width';
//show when the button is clicked
toastr.success('Click Button', 'ButtonClick', 'positionclass = "toast-bottom-full-width"');
});
Thanks @John。我从给出的例子中找出了出于某些原因,我需要设置它2次才能使其工作。谢谢你真棒图书馆 – swapneel
@JohnPapa你能解释一下这个吗?我已经尝试将我的文档准备好,并且在我致电toastr.warning之前。它似乎并不需要。顺便说一句我只是想改变showDuration,所以我的选项看起来像这样:'toastr.options = {showmore.com“:”20000“, }' – wilblack
版本'2.0.2'有一个问题,其中'positionClass'不是在所有情况下都受到尊重:[请参见GitHub上的问题](https://github.com/CodeSeven/toastr/issues/156)。它固定在'2.0.3'中,但是在我写这篇评论的时候,还没有2.0.3版本。 – Scott