I have read the posts & documentation on Javascript snippets, and I understand that it is not really a supported feature, but is there a way I can integrate javascript with foreUI elements? I need to do something like:
Set “TextBox_1” value to myJavascriptFunction( <a_ForeUI_Userdefined_Property> )
Thanks!
Roy
2 answers
Hi Roy,
It is possible to do it by calling some ForeUI predefined functions in the “Call Javascript Snippet” action. Let’s say you defined a function named “myfunc” in the “Script” element:
Then in the “Call Javascript Snippet” action, you can put the content below:
Then you will see it updates the text of TextBox_1, to doubled value of property “tmp” (please notice the property expression is {“tmp”} in EVAL mode, needs quote marks for property name).
===================================================================
I really want to use a nicer way to do it, like this:
It really should work, but unfortunately it doesn’t, because of a bug: diagnose engine doesn’t see the myfunc function in Script element, and will regard it as an error. As a result, this action will not get exported to the HTML5 simulation.
We will try to fix that bug in next version, then you will be able to use that nicer approach 🙂
-
Hi ViVi, is this "nicer way to do it" implemented in version 4.20? I'm trying to call a JavaScript element to generate the content of a TextBox element from the "Manipulate Elements" dialog, but it's not working for me. I can't tell whether I have an error in my syntax in Step 3, or if the problem is that this approach still won't work from "Manipulate Elements" in version 4.20. (BTW, I'm on the third day of my evaluation of this product and I love it! Thanks for all the hard work!)
-
We have something better now, although it is not a final solution yet. Please see my new answer below.
There is a nicer way that can work, but still it is a workaround.
There are two key points:
- You can turn off the diagnose for certain line of behavior, so it will not disable that line by mistake.
- You can define the Javascript function in the “Call Javascript” action.
Below is an example that I tried and confirmed it is working.