When I respond to a web event, I would like to make a previously actioned(?) notify box disappear. Is there a KRL way to tell it to go away or does it have to be done through javascript?
If it must be done through javascript, please provide an example
All my previous answers suck! What you really should do is trigger the click event on the close button.
$K(".kGrowl-notification .close").trigger("click");
Just emit that JavaScript when you are responding with a web event.
Better example app:
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")
|>;
}
}
}
There are several ways you could accomplish this.
Examples:
set_element_attr
set_element_attr(".kGrowl", "style", "display:none");
emit [remove] (evil)
emit <|
$K(".kGrowl").remove();
|>;
emit [hide]
emit <|
$K(".kGrowl").hide();
|>;
replace_html (evil)
replace_html(".kGrowl","");
Full app example:
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","");
}
}
}
Example app bookmarklet: => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-clear-notify-dev_bookmarklet.html
Example app run on example.com:
clear button clicked: