Page 1 of 1

Appery Click Coding for Javascript

Posted: Fri May 02, 2014 8:44 am
by David Lim

I want to ask is there a Click function for Javascript,
Where user Click a Image Component , Another Image appear for multiply times as the user click.


Appery Click Coding for Javascript

Posted: Fri May 02, 2014 8:55 am
by Serhii Kulibaba

Hello David,

You can add click event handler for any component. http://docs.appery.io/documentation/w...


Appery Click Coding for Javascript

Posted: Fri May 02, 2014 9:08 am
by David Lim

Can it be done in Javascript?
Since i may be using "if" "else" when is the user click repeatly and different image appear on a same image component


Appery Click Coding for Javascript

Posted: Fri May 02, 2014 11:18 am
by Serhii Kulibaba

Sure, you can do it. Just save count of clicks in localStorage.
For example:
var clicks = parseInt(localStorage.getItem("clicks"));
if (clicks ) == 0){
Apperyio("imageName").attr("src","http://example.com/image1.png");
} else {
Apperyio("imageName").attr("src","http://example.com/image2.png");
}
localStorage.setItem("clicks", clicks + 1);

Note: imageName - name of image component