Jayrok94
Jayrok94

Reputation: 129

How to permanently Disable a button

I have a button that saves a contact to the device and then sets the button to disable this is good but everytime you reopen the app the button is enabled again how do you permanently disable a button?

Upvotes: 0

Views: 116

Answers (2)

Sven Tore
Sven Tore

Reputation: 987

When en application is started again it's a new session, so you have to store the state of the button, and disable it again on every start up.

There is many methods to store more or less statefull data, the on to choose is dependent on what kind of statefullness you would like.

e.g: Do you want a new user to have the button enabled? Do you want the same user to have the button disabled if used on another device? Should the state be stored across different browsers or if the users clears the browser cache?

Your question is not precise on how long you want or need to store the state, but you may want to look into localStorage If you only need to store this one, or a few, data items you could create a new model, with one field per data you need to store, and give the model a Ext.data.proxy.LocalStorage proxy.

Then, when the button is clicked and disabled, you also create a record and store in in the browser. When in the application start up you have to check for the existence of the record and the value of your buttonShouldBeDisabled field and decide if the button should be disabled based on that.

The other approach is server-side storage, but then you would want some kind of user authentication and you could store the state/preferences etc along the use user information, and receive it after login.

Upvotes: 1

Vlad
Vlad

Reputation: 3645

disabled: true

In button config.

Upvotes: 0

Related Questions