Page 1 of 1

How to implement a Counter

Posted: Tue Feb 07, 2012 12:22 am
by mcgrathken.kmg

Hey Guys
Anybody know how to implement a simple counter in Tiggzi.
Let's say , an input field and a "-" button on one side and a "+" button on the other.
So basically, when the user clicks on a button the counter will increase and decrease accordingly.
I may require custom JavaScript an invoke on the click event ? or maybe I can set a variable and increment on click or something.Also i need to store the variable locally for distribution to Parse.

Thanks


How to implement a Counter

Posted: Tue Feb 07, 2012 1:04 am
by maxkatz

Yes, you would need to define a variable, then two buttons with click events. One button will decrease the value, one button will increase the value. As for sending to Parse, it's like any other input, just map the value to service input.


How to implement a Counter

Posted: Tue Feb 07, 2012 2:09 am
by maxkatz

Image

On button click run this:

To add one:
code
var v = Tiggr ('countLabel').text();
Tiggr('countLabel').text(++v);
/code

To subtract one:
code
var v = Tiggr ('countLabel').text();
Tiggr('countLabel').text(--v);
/code

countLabel - name of the Label component.


How to implement a Counter

Posted: Tue Feb 07, 2012 2:10 am
by maxkatz

I created a 'test' screen in your app where this is implemented.


How to implement a Counter

Posted: Tue Feb 07, 2012 11:37 pm
by mcgrathken.kmg

Great Max.....This works Perfect