我在调用回调时遇到了一些问题。我的前缀是我跟着this链接,但它现在无法正常工作。
我需要做的是在通知中点击一个新页面。目前,即使是简单的警报也未显示。
我的代码如下
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;
// }
}
我做错了什么? 感谢
我仍然面临着传递价值的问题"楼下"
考虑这个片段
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");
}
}
}
我得到null作为id,在回调之外它没关系,我做错了什么? 再次感谢
答案 0 :(得分:1)
对于提供的链接,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');
};