This is a simple flow demonstrating how to send messages to javascript in a Dashboard Template node and how to send messages back to the flow from javascript. In addition it shows how to send a message to node-red when the view is opened in a browser, which is useful for preloading data into the view when it is first opened.
As is shown in the flow exactly the same code can be used in two templates, each picking up messages from node-red and sending responses back.