I am having an issue using remoteCommands with a JavaScript DOM Listener. I have a listener defined like so on a JSF page:
<script>
$(document).keydown(function(e) {
onEnter();
}
</script>
And a remote command defined like so:
<p:remoteCommand name="onEnter" action="{primeView.onEnter(iter)}" style="display: none;"/>
For what its worth, the remoteCommand is within a p:dataTable
with var=iter
. I’ve also tried adding process="@form"
and immediate="true"
, with no change.
When pressing any key on the page, the JavaScript listener is called, but the following error is output:
Uncaught ReferenceError: onEnter is not defined
I’m assuming this is because DOM listeners have a different scope that normal native JavaScript. So, how can I access the remoteCommand from within a listener?