如何永久禁用按钮

时间:2023-01-10 15:53:53

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?

我有一个按钮,可以保存与设备的联系,然后设置按钮以禁用此功能,但每次重新打开应用程序按钮再次​​启用时,如何永久禁用按钮?

2 个解决方案

#1


1  

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.

您的问题不确定您想要或需要存储状态的时间长度,但您可能需要查看localStorage如果您只需要存储这一个或几个数据项,您可以使用一个字段创建一个新模型您需要存储的每个数据,并为模型提供Ext.data.proxy.LocalStorage代理。

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.

然后,当单击并禁用该按钮时,您还可以在浏览器中创建记录并存储。在应用程序启动时,您必须检查记录是否存在以及buttonShouldBeDisabled字段的值,并确定是否应根据该按钮禁用该按钮。

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.

另一种方法是服务器端存储,但是你需要某种用户身份验证,你可以在使用用户信息中存储状态/首选项等,并在登录后接收它。

#2


0  

disabled: true

In button config.

在按钮配置中。

#1


1  

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.

您的问题不确定您想要或需要存储状态的时间长度,但您可能需要查看localStorage如果您只需要存储这一个或几个数据项,您可以使用一个字段创建一个新模型您需要存储的每个数据,并为模型提供Ext.data.proxy.LocalStorage代理。

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.

然后,当单击并禁用该按钮时,您还可以在浏览器中创建记录并存储。在应用程序启动时,您必须检查记录是否存在以及buttonShouldBeDisabled字段的值,并确定是否应根据该按钮禁用该按钮。

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.

另一种方法是服务器端存储,但是你需要某种用户身份验证,你可以在使用用户信息中存储状态/首选项等,并在登录后接收它。

#2


0  

disabled: true

In button config.

在按钮配置中。