divクリック時に私のトーストのpositionclassを変更しようとしています。toastr通知のポジションクラスを変更する
とポジションクラス:ボトムに変更されません。私はここで何が欠けていますか?
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>
更新私はtoastr.jsからGETOPTIONS以下の方法が 「positionclass:トーストボトム全角」をオーバーライドしていることに気づいたデバッグ後1
に「乾杯トップ
function getOptions() {
return $.extend({}, defaults, toastr.options);
}
アップデート」右回転2林toastr.jsのe 140はではありません。 mを延長します。 オプションをオプションにオーバーライドしますか?
if (typeof (map.optionsOverride) !== 'undefined') {
options = $.extend(options, map.optionsOverride);
iconClass = map.optionsOverride.iconClass || iconClass;
}
更新3 Postionの問題が修正されましたが、私は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"');
});
ありがとう@ジョン。私はいくつかの理由で私はそれを動作させるために2回それを設定する必要があります与えられた例から考え出した。すばらしい図書館ありがとうございます – swapneel
@JohnPapaこれをどこに置くべきか説明できますか?私はonreadyを書類に入れようとしました、そして、toastr.warningへの私の呼び出しの前にも。それは取るようではありません。ところで、私はshowDurationを次のように変更しようとしています: 'toastr.options = { " showDuration ":" 20000 "、 } – wilblack
バージョン' 2.0.2'では 'positionClass'が問題になりません全ての場合において尊重されています:[GitHubに関する問題を参照](https://github.com/CodeSeven/toastr/issues/156)。これは '2.0.3'で修正されましたが、私がこのコメントを書いている時点ではまだ' 2.0.3'のリリースはありません。 – Scott