Hi, new user here. . . I can’t seem to find out how to add a JS function to a button click. For example, I want to open a new window via JS when the user clicks a button. I can add it manually to the HTM file, but is there a way from within the ForeUI app?
Thanks,
John
4 answers
Hi John, you will need to define the behavior for the button in the “Bahavior” view. You can follow this document to do so: http://www.foreui.com/doc/html/elemen…
In the example you mentioned, you will need to handle the “Element Clicked” event for the button, and use the “Go to URL” action to open new window in the event handler. You should have behavior defined like this:
Hi Vivi,
Thanks for your suggestion. I can execute any action fine, but I want to execute a javascript function (i.e. openLogWin() ). I don’t see how this is possible.
Suggestions?
Thanks!
John
Hi John, well it is possible, but that is kind of hack instead of officially supported feature.
The expression in the Delay interval could actually be used as a place to call Javascript function. For example:
We will add a new action in ForeUI, to officially support calling predefined Javascript function, so you won’t need the hack then.
Hi ViVi,
Thanks for the quick reply. I am hacking the HTML code manually now, so this is better. Even better will be the addition of the ability to call javascript function from within the I/F.
Cheers.
-
Calling function in IF was possible, but it isn't now since ForeUI will verify the expression in the IF. Since ForeUI doesn't know your external function, the verification will fail and the function call will not actually be included in the simulation.
-
I actually added the JS function into the ForeUI with the Javascript Code element and all is working fine with the delay hack above. Thanks!
-
You are welcome :-)
This question is now closed