View Full Version : Click-once Button

5 Sep 2011, 4:29 PM
Hi, I have just started going through some tutorials in Sencha Touch and have progressed past some basic ones and the moment I wanted to do something on my own I got stuck and hopefully someone could point me in the right direction :/

Currently on the first screen, I have set-up a simple list of items that is retrieved and sync'd through a rest proxy on my server and it does an onItemDisclosure that shows its details on another screen. What I would like to do is sort of a button that mimics the fb like button or +1 buttons that only lets a user click it once per session (Etc: not submit buttons that blocks while its submitting)

How should I be approaching this? Must the server store all these information of each user or maybe session management or cookies or is there a smarter way to do this through stores?

I have tried hiding the like button on that form, and showing a different button but that doesn't seem to work since other items would show the new button as well when they render the same form...

Yup that's about as far as I got, and thanks for getting through this long message! Let me know if there is any other information I need to provide.


6 Sep 2011, 5:36 AM
What I would do is setup a LocalStorage Store that saves these things. On load of app, remove all records. Then check this Store when the Component (FormPanel or whatever you are using) to see if you should show it or not. Honestly, I would disable the button or change the ui if the button was already pressed instead of hiding it. People could (and lots would) wonder what happened to the button and may think it's a bug.

If you change the ui of the button, then when it is pressed you can pop up a message telling them they can only press it once per session.

6 Sep 2011, 5:57 PM
thanks for the reply and recommendations, I went on with localstorage, storing some IDs to identify the items he clicked and it seems pretty much what I wanted for this test-run! Then again, theres a but,

It seems that the localstorage can be edited by web browsers (like chrome), is this how people usually do it? I mean if it is able to be manipulated, wouldnt it be a little dangerous? Is there anyway around this with localstorage?


7 Sep 2011, 11:55 AM
Yes, localstorage can be altered or cleared. That is why a backend still needs to be around to support the security of your app. No matter what way you do it (Ajax request to figure permissions), anything client side can be changed. I can go in and figure out how to add buttons, enable buttons, do what I wish... but 98% of the people out there won't.

7 Sep 2011, 5:09 PM
Its a pity its not lockable, seeing it might simplify much of backend works. Well looks like I'll be building a proper backend before I restart on this one~

Anyways, thanks again(: