I have an appjs application running well. I am trying to basically either call an existing javascript function from within the loaded page on an event. OR access the pages elements on an event. I am using the node-serial library with a Honeywell Barcode Scanner. I can access the serial port fine, I can get the scan data just fine with:
serialPort.on('data', function(data) { ... });
What I want to be able to do is, as stated above, call a javascript function on the page i.e.
window.document.body.scan(data);
OR at least access the data and be able to call / make http requests with node, which i'm able to do fine as well. When I run these things in the
window.on('ready', function(){ ... });
I'm able to access the elements on the page just fine. i.e.
var $ = window.$;
$("#message").html('Something...');
But if i try to run the exact same code in the serialPort.on data function i get errors like
$('#message').html('Please wait...');
^
TypeError: object is not a function...
Or even $("#message").html that "html" is not a function. But if i run it on the window.on ready function it works. I'm pretty lost as there is very little documentation for appjs. Thank you!