change attribute via html/javascript widget

0
HI all. so I'm trying to retrieve a string from an iframe using some javascript, the page in the iframe is sending a postmessage to my parent page (the mendix page) and I've used an html/javascript widget to create the eventlistener, and place this string in an attribute's text box. So far so good, I am seeing the text appear in the box, but the problem is, that on committing the object, Mendix does not recognise the text in the textbox (it's always empty), so clearly it is treating the text differently to if it was inputted by the user.   the JS looks like this:  window.addEventListener("message", function(event){ var textarea = document.getElementById('mxui_widget_TextArea_0'); textarea.value = event.data; }, false);   Basically, is there a way to make this work, or a better way of doing this? the important thing here is I need to retrieve the string from the iframe, with no direct user input, and it needs to find it's way into the attribute, and be saved to db.
asked
1 answers
5

Have you tried getting the mendix object and setting the attribute directly? You can get a reference to the object from dojo and then use the Client API to set the attribute.

Something like:

dijit.registry.byNode(textarea).mxcontext.getTrackObject().set("MyAttribute",message);

Thanks to Fabian for the correction on using the dijit namespace to access the registry.

answered