我正在使用引导程序通知来向最终用户显示参考消息。http://goodybag.github.io/bootstrap-notify/
我有一个DIV
电话
<div class="notifications bottom-right"></div>
从理论上讲,该库应该处理我已确保已加载该库的JS,但现在仍没有通知窗口显示,我不知道为什么我希望在页面加载时发生这种情况,因此会告诉用户是否有待处理的点。
我将如何修改script标签以通过PHP
?来实现。
<script>
$('.bottom-right').notify({
message: { text: 'Aw yeah, It works!' }
}).show(); // for the ones that aren't closable and don't fade out there is a .hide() function.
</script>
编辑以显示我已使用wp enque obv的标题中的文件
<script type='text/javascript' src='http://fundrasing.davidbuckleyni.co.uk/wp-content/themes/gogreensoccer5/js/bootstrap-notify.js?ver=201202012'></script>
<link rel='stylesheet' id='notifcations-css1-css' href='http://fundrasing.davidbuckleyni.co.uk/wp-content/themes/gogreensoccer5/css/bootstrap-notify.css?ver=1.0' type='text/css' media='all' />
<link rel='stylesheet' id='notifcations-css2-css' href='http://fundrasing.davidbuckleyni.co.uk/wp-content/themes/gogreensoccer5/css/styles/alert-blackgloss.css?ver=1.0' type='text/css' media='all' />
<link rel='stylesheet' id='notifcations-css3-css' href='http://fundrasing.davidbuckleyni.co.uk/wp-content/themes/gogreensoccer5/css/styles/alert-bangtidy.css?ver=1.0' type='text/css' media='all' />
工作示例:https : //jsfiddle.net/mwatz122/1k3s7m80/
确保包括所有必需的库(CSS和JS)。在我的jsfiddle例子,我已经包括bootstrap-notify.min.css
,alert-bangtidy.min.css
,alert-blackgloss.min.css
,和bootstrap-notify.min.js
从CDN。
如果希望在页面加载时显示通知,则应在$(document).ready
所示的块中包含JavaScript代码。
<div class='notifications bottom-right'></div>
$(document).ready(function () {
$('.bottom-right').notify({
message: {
text: 'Aw yeah, It works!'
}
}).show();
});
编辑:
页面加载时,您的网站抛出错误:
Uncaught TypeError: $(...).notify is not a function
这意味着bootstrap-notify.min.js
未检测到源文件。我会尝试先引用CDN,以确保您可以使用它。您应该在标题中包含jQuery
和Bootstrap
之前bootstrap-notify.min.js
。您可以将其用作CDN链接https://cdnjs.cloudflare.com/ajax/libs/bootstrap-notify/0.2.0/js/bootstrap-notify.min.js
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句