gpt4 book ai didi

krl - 如何使 "notify"框消失

转载 作者:行者123 更新时间:2023-12-02 00:36:36 26 4
gpt4 key购买 nike

当我响应网络事件时,我想让之前操作过的(?)通知框消失。是否有 KRL 方法告诉它消失,还是必须通过 javascript 完成?

如果必须通过javascript完成,请提供示例

最佳答案

新 Shiny 令人敬畏的答案!

我之前的所有回答都很糟糕!您真正应该做的是触发关闭按钮上的点击事件。

$K(".kGrowl-notification .close").trigger("click");

当您响应网络事件时,只需发出该 JavaScript。

更好的示例应用:

ruleset a60x469 {
meta {
name "better-close-notify-example"
description <<
better-close-notify-example
>>
author "Mike Grace"
logging on
}

rule put_notify_on_page {
select when pageview ".*"
{
// put notify on page
notify("Hello","I'm on your page") with sticky = true;

// raise web event
emit <|
setTimeout(function() {
app = KOBJ.get_application("a60x469");
app.raise_event("clear_notify");
}, 2000);
|>;
}
}

rule clear_notify {
select when web clear_notify
{
emit <|
$K(".kGrowl-notification .close").trigger("click")
|>;
}
}
}

陈腐的回答


您可以通过多种方式实现这一目标。

示例:

设置元素属性

set_element_attr(".kGrowl", "style", "display:none");

发出[移除](邪恶)

emit <|
$K(".kGrowl").remove();
|>;

发出[隐藏]

emit <|
$K(".kGrowl").hide();
|>;

replace_html(邪恶)

replace_html(".kGrowl","");

完整应用示例:

ruleset a60x468 {
meta {
name "example-clear-notify"
description <<
example-clear-notify
>>
author "Mike Grace"
logging on
}

rule put_notify_on_page {
select when pageview ".*"
pre {
button =<<
<button id="clear-notify">Click me to clear the notify</button>
>>;
}
{
notify("Hello","I'm on your page") with sticky = true;
append("body", button);
emit <|
$K("#clear-notify").click(function() {
app = KOBJ.get_application("a60x468");
app.raise_event("clear_notify");
});
|>;
}
}

rule clear_notify {
select when web clear_notify
{
replace_inner(".kGrowl","");
}
}
}

示例应用书签:=> http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-clear-notify-dev_bookmarklet.html

在 example.com 上运行的示例应用程序:

alt text

点击清除按钮:

alt text

关于krl - 如何使 "notify"框消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4383165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com