Javascript .value() on Textarea doesnt update Mendix

0
I populate my textarea with certain data through Javascript, but this data is not picked up by Mendix.  Let's say I open the page and the textarea is empty. I click a button to trigger the javascript and see text inside the textarea. When I debug the microflow behind the 'next’ button, the value of that attribute is still "” (empty). When I manually change the value, the text is suddenly recognized. How do I make Mendix see the text inside the textarea, like the user sees it?   I've already tried “.trigger(‘change’)” or simply “.change()”, without effect.   Context: A user uploads a file and upon upload this file is compressed, client-side, returning a base64 string that is pasted inside a (hidden) textarea. Through a microflow, this Base64 is retrieved, decoded into a file and attached, instead of the file with (large) original size. 
asked
1 answers
5

Hi Sander, 

To set an attribute in javascript you have to use the Mendix client API. 

From the documentation:

mxobj.set("Name", "Henry");  

This sets the attribute called “Name” with the value “Henry”.

 

 To get a hold of the context object with the javascript snippet or html snippet you can use:

var mxobj = this._contextObj;

 

Here is a link to the mx7 and mx8 client api. 

https://docs.mendix.com/apidocs-mxsdk/apidocs/client-api

 

 

Hope this helps!

answered