I'm defining a Javascript function in my KRL global block that I want to call when the user clicks a link. Here are the relevant parts of the ruleset:
global {
emit <|
function clear_hold() {
app = KOBJ.get_application("a421x26");
app.raiseEvent("clear_hold");
}
|>;
}
rule add_link_to_clear_hold {
select when pageview ".*"
pre {
clear_div = << <div id="clear_hold">
<a href="javascript:clear_hold()">Clear Hold</a>
</div> >>;
}
{
append("body", clear_div);
}
rule clear_the_hold {
select when web clear_hold
{
replace_html("#clear_link", "<div id='clear_link'>Not on hold</div>");
}
always {
clear ent:hold;
}
}
When I click the link I get an error message that clear_link
is not defined.
What do I need to do to call my javascript function?