javascript - 当用户从确认框中选择否时,如何设置单选按钮的旧值?
问题描述
我有一个问题,当用户在单选按钮上进行更改时,我必须触发用户确认框。
我成功触发了确认框,但对我来说很难在无线电组中设置旧值。任何人都有这样做的想法。我尝试在谷歌上提到解决方案,但没有运气。
Ext.define('CustomRadioField', {
override: 'RadioField',
setListeners: function(config) {
var me = this;
config.listeners = {
change: {
fn: function(control, newValue, oldValue, eOpts) {
var me = this;
me.fieldChanged();
Ext.Msg.confirm(MyFunction.T('Confirm'), "Are you sure want to delete?", function(btn) {
if (btn == 'no') {
//Added my logic to reset back
control.suspendEvent('change');
control.setValue(oldValue);
control.resumeEvent('change');
//End
//Added to refresh page not to reload but this location.reload post to my server insted to refresh.
location.reload();
}
if (btn == 'yes') {
}
});
}
},
scope: me
},
focus: {
fn: me.storeFocusField,
scope: me
},
afterrender: {
fn: function(f, e) {
me.setFieldFocus;
},
scope: me
},
boxready: {
fn: me.setUpChangeEvent,
scope: me
},
specialkey: {
fn: function(f, e) {
var me = this;
switch (e.getKey()) {
case e.TAB:
break;
}
},
scope: me
}
};
},
});
提前致谢
解决方案
你能附上代码吗?
您可以使用field.reset()
函数重置字段值,其中字段是单选按钮字段,或者您可以使用form.reset()
方法将表单中的所有字段重置为用户更改之前的状态。
推荐阅读
- apache-spark - SecurityManager:禁用身份验证;ui acls 禁用;具有查看权限的用户:
- asp.net - Object Required 424 错误只发生在 IE11
- c# - 按名称动态获取常量的嵌套值
- python - Ubuntu16.04 python3.6.5无法安装tensorflow
- javascript - 如何从存在多个局部视图且每个局部视图没有提交按钮的视图中将值设置为 db?
- c# - C# - 从 Windows 服务启动 Windows 窗体
- android - AndroidPublisher API 404 带有“找不到符号文件的 APK”。尝试上传 Android App Bundle 时
- vue.js - 在渲染之前将 ajax 获取的数据设置为组件
- ios - UITableViewCell 有时不会在编辑模式下选择
- ios - 在 swift 项目中导入 PayPal-iOS-SDK