我在我的php代码中添加了jAlert框,用于一个警报。正常window.confirm()
工作正常,但我添加jAlert它不起作用。我为jAlert包含了css和js文件。
echo "
<script type=\"text/javascript\">
$.fn.jAlert({
'title': 'Activity :- Search',
'message': 'Are you sure you want to display more than 250 activities?',
'theme': 'info',
'btn': [
{'label':'Yes', 'cssClass': 'green', 'closeOnClick': true, 'onClick': function()
{
window.location.href = ('home.php');
}
},
{'label':'No', 'cssClass': 'red', 'closeOnClick': true, 'onClick': function()
{
window.location.href = ('logout.php');
}
}
],
'autofocus': 'btn:first'
});
</script>
";
请帮我解决这个问题。提前致谢
答案 0 :(得分:0)
将$ .fn.jAlert包装在$(function(){
中在执行代码之前,似乎没有加载插件。
决赛应该是这样的:
echo "
<script type=\"text/javascript\">
$(function(){
$.fn.jAlert({
'title': 'Activity :- Search',
'message': 'Are you sure you want to display more than 250 activities?',
'theme': 'info',
'btn': [
{'label':'Yes', 'cssClass': 'green', 'closeOnClick': true, 'onClick': function()
{
window.location.href = ('home.php');
}
},
{'label':'No', 'cssClass': 'red', 'closeOnClick': true, 'onClick': function()
{
window.location.href = ('logout.php');
}
}
],
'autofocus': 'btn:first'
});
});
</script>
";