Discussion
Turkiye Finans Kat?l?m Bankas?
TR
Last activity: 16 Nov 2016 7:52 EST
call javascript function
Hi.
I write javascript function then I saved it in HTML fragment. my function is simply (<script> function jsTest(){ alert(Deneme);}</script>)
How can I call the function in button click action
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
Harun,
You didn't say which version of Pega you are using or exactly what you are trying to accomplish. If all you want to do is bring up a message you should just use the "Local Action" as the action an event on the button and make the target "modal dialog".
This was tested in 7.1.4 but should work in earlier versions. To use the fragment in a section you first need to wrap it in a non auto-generated section like so:
Then you can include this section in your section. To have a button click run your script add a click event and expand the list of actions, choose Run Script and insert the name of your script. Also you need to fix your script you left out some quotes:
<script> function jsTest(){ alert("Deneme");}</script>
Turkiye Finans Kat?l?m Bankas?
TR
hi
my version is 7.1.7
I just running javascript function that saved in Html fragment.
I saved "<script> function jsTest(){ alert("Deneme");}</script> " in html fragment then
I want to call this saved js function on button click.
when I click button I want to see alert message "Deneme".
Turkiye Finans Kat?l?m Bankas?
TR
hi howec
I have done it as your said.it works
but I have a question.
why I must insert new section in my section.
if I need to add a new section why we need adding js file in html fragment ?
Pegasystems Inc.
US
Harun,
Please see my post above where I show you how to accomplish exactly what you are asking. I ask what you are trying to accomplish because I am assuming displaying "Deneme" is just a test to see if you can run javascript which you then intend to use to accomplish some objective other than a simple alert. It is always better to run a built in Pega feature when available, as I stated in my previous post if all you want to do is show a messge on a button click then using an html fragment is most likely not the best way to do it. If you are trying to accomplish something else then again perhaps html fragment is not the best way, this is the reason I ask what you are trying to accomplish beyond just showing "Deneme".
Sincerely,
Cecil
Turkiye Finans Kat?l?m Bankas?
TR
Hi howec
you are right. "Deneme" is just a test message , I will not use it our project.
as you said I intend to use some objective other than a simple "Deneme" alert.
I want to learn why I must add file in HTML fragment. because I can run java scripts in section's html part without adding a file in HTML Fragment.
HCL Technologies
IN
Hi Harun,
I think you can use the Run Scipt function from actions Tab. Go to the current harness in which the button is placed Then go to Scripts and Styles below you will find something called Scripts click the type and select as JS and give the Functiion name. Click on search icon to open the Function and write your piece of code there. I hope it will work
Pegasystems Inc.
IN
Run Script action may suit your needs, please check the screenshot.