jquery – 更改toastr通知的positionclass
我正在為div點選改變我的吐司的positionclass.
positionclass:is not changed to Bottom.? what am i missing here?
以及如何使用
toastr.optionsOverride = ‘positionclass:toast-bottom-full-width’;
@{ 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:toast-bottom-full-width’to’toast-top-right’
function getOptions() { return $.extend({}, defaults, toastr.options); }
更新2 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"'); });