Alertify.js 通知的回调未触发
Alertify.js notification's callback not fired
我在调用回调时遇到了一些问题。我前缀我已经关注 this link 但它现在不起作用。
我需要做的是在通知中点击一个新页面打开。目前,即使是简单的警报也不会显示。
我的代码如下
switch (obj.Status) {
//case "OK":
// {
// alertify.message(obj.Message, timeout);
// break;
// }
case "KO":
{
alertify.message(obj.Message, timeout);
alertify.callback = function () {
//if(isClicked)
// alert('notification dismissed by user');
//else
alert('notification auto-dismissed');
};
break;
"Warn":
// {
// alertify.warning(obj.Message, timeout);
// break;
// }
}
我做错了什么?
谢谢
更新 #1
我仍然面临传递“楼下”值的问题
考虑这个片段
chat.client.updateNotifications = function (message) {
var obj = JSON.parse(message);
var guid = obj.RequestId;
var notify = function(level, msg) {
var func;
switch (level) {
case "success":
func = alertify.success;
break;
case "error":
func = alertify.error;
break;
case "warn":
func = alertify.warn;
break;
}
var m = func(msg, timeout);
m.id = guid;
m.callback = function(isClicked) {
if (isClicked) {
var url = '<%=Url.Action("Index","Import",new {id = -1})%>';
url.replace("-1", this.id);
// alert(url);
window.open(url, "target=_blank");
}
}
}
我得到的id为null,在回调之外没问题,我做错了什么?
再次感谢
参考提供的link,callback
是返回通知对象的属性(不是alertify
)
//this call returns a notification object.
var msg = alertify.message('Open up your web console', 10);
//set the callback on the notification object.
msg.callback = function (isClicked) {
if(isClicked)
console.log('notification dismissed by user');
else
console.log('notification auto-dismissed');
};
我在调用回调时遇到了一些问题。我前缀我已经关注 this link 但它现在不起作用。
我需要做的是在通知中点击一个新页面打开。目前,即使是简单的警报也不会显示。
我的代码如下
switch (obj.Status) {
//case "OK":
// {
// alertify.message(obj.Message, timeout);
// break;
// }
case "KO":
{
alertify.message(obj.Message, timeout);
alertify.callback = function () {
//if(isClicked)
// alert('notification dismissed by user');
//else
alert('notification auto-dismissed');
};
break;
"Warn":
// {
// alertify.warning(obj.Message, timeout);
// break;
// }
}
我做错了什么? 谢谢
更新 #1
我仍然面临传递“楼下”值的问题
考虑这个片段
chat.client.updateNotifications = function (message) {
var obj = JSON.parse(message);
var guid = obj.RequestId;
var notify = function(level, msg) {
var func;
switch (level) {
case "success":
func = alertify.success;
break;
case "error":
func = alertify.error;
break;
case "warn":
func = alertify.warn;
break;
}
var m = func(msg, timeout);
m.id = guid;
m.callback = function(isClicked) {
if (isClicked) {
var url = '<%=Url.Action("Index","Import",new {id = -1})%>';
url.replace("-1", this.id);
// alert(url);
window.open(url, "target=_blank");
}
}
}
我得到的id为null,在回调之外没问题,我做错了什么? 再次感谢
参考提供的link,callback
是返回通知对象的属性(不是alertify
)
//this call returns a notification object.
var msg = alertify.message('Open up your web console', 10);
//set the callback on the notification object.
msg.callback = function (isClicked) {
if(isClicked)
console.log('notification dismissed by user');
else
console.log('notification auto-dismissed');
};