Okay - I have a text element named ‘InternalMessageReceiver’ and have edited its inner HTML thus:
Receiver
<script language="javascript">
function messageReceived() {
alert ( "Received the message!" );
}
</script>
I have a button in my document; its onClick action is intended to activate the function in the inner HTML of my text element. I’ve tried a couple variants to activate that function:
hypeDocument.getElementById("InternalMessageReceiver").messageReceived;
…and:
HYPE.documents['MessagingTest'].functions().messageReceived();
…however, in both cases the code fails (the document is named ‘MessagingTest’). For the first example nothing happens at all; for the second example the error is:
[Log] Error in sendMessage: TypeError: undefined is not an object (evaluating ‘HYPE.documents[‘MessagingTest’].functions’) (HYPE-466.thin.min.js, line 14)
It seems clear I’m not getting to the function in the text element.
I’m doing this as an isolated test to determine if/how to send calls to functions in elements’ inner HTML, with the goal, eventually, of attaching functions to an HTML widget that will allow me to pass parameters.
Ultimately my purpose is to load a custom Google Maps view in a widget, using JQuery to get the user’s location, and load a map with their LatLong centered in the map view. I’ve been able to get location, so that much at least is working. I’ve also been able to load a static map view, but it’s loading based on hard-set parameters copy/pasted from a Google Maps iframe embed.
To move on to the next step, I’ll need to be able to pass the user’s LatLong parameters to the map view; that’s why I believe what I need to do is be able to message custom functions attached to a widget’s inner HTML. (If there’s another way to do this, feel free to suggest it…)
I’d like to be able to do other things as well, such as toggle map pins of various kinds based on what the user wants to see (i.e., show or hide locations of restaurants, amusement parks, zoos, whatever); again, in order to do this I think I’ll need to send messages to the widget that contains the map view.
Since I want the view to be dynamic based on multiple user-set parameters, I don’t know of any other way to do this … and it seems I can’t even begin to address the simplest of custom functions in an element’s inner HTML.
Am I missing something obvious here?
Sample stub file is attached.
MessagingTest.hype.zip (16.3 KB)