Page 1 of 1

How to call a function on click event

Posted: Mon Dec 15, 2014 7:45 pm
by Solomon Habtu

Halo, I put a simple js in JavaScript menu and I would like to call it when a button is clicked. What type of js line shall I write on click even?


How to call a function on click event

Posted: Mon Dec 15, 2014 7:55 pm
by Evgene Karachevtsev

Hello Solomon,

On click event you may choose action Run JS and put your code there.


How to call a function on click event

Posted: Tue Dec 16, 2014 4:49 pm
by Solomon Habtu

Sorry Evgene K. for confusing you. based on the step "Create New -Java Script", I already put a java script named "refresh.js" in my project JavaScript directory . rather than copy and pest every were I would like to call it on click even. So what kind of method or on click Run JS action to call "refresh.js" .
thanks


How to call a function on click event

Posted: Wed Dec 17, 2014 2:59 am
by Yurii Orishchuk

Hi Solomon,

JS asset - injects as JS file.

It runs at application load.

If you have some functionality in this JS asset you should wrap it with some function. Example:

pre

function RunMyFuncFromMyAsset(){
alert("RunMyFuncFromMyAsset run");
//Here is your implementation.
};

/pre

Then you need to add "Run javascript" action on button "click" event and use following JS code:

pre

//Run function from your JS asset.
RunMyFuncFromMyAsset();

/pre

That's how JS works.

Regards.


How to call a function on click event

Posted: Thu Dec 18, 2014 6:39 am
by Solomon Habtu

you solved it, thanks, a lot.