我想改變位置類爲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