Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用模态确认多次更新输入_Javascript_Jquery_Callback_Modal Dialog - Fatal编程技术网

Javascript 如何使用模态确认多次更新输入

Javascript 如何使用模态确认多次更新输入,javascript,jquery,callback,modal-dialog,Javascript,Jquery,Callback,Modal Dialog,我需要在请求后分别确认几个字段。用户需要在新值和旧值之间做出选择。Modal正在更新覆盖文本的输入,不等待确认。它仅在最后一个事件中显示,然后确认答案设置为所有其他答案。我在研究中没有找到多少帮助,我也不知道如何解决它 var modalConfirm=函数(回调){ $(“#gti模态btn是”)。单击(函数(){ 回调(true); $(“#gti modal”).hide(); }); $(“#gti模态btn编号”)。单击(函数(){ 回调(假); $(“#gti modal”).hi

我需要在请求后分别确认几个字段。用户需要在新值和旧值之间做出选择。Modal正在更新覆盖文本的输入,不等待确认。它仅在最后一个事件中显示,然后确认答案设置为所有其他答案。我在研究中没有找到多少帮助,我也不知道如何解决它

var modalConfirm=函数(回调){
$(“#gti模态btn是”)。单击(函数(){
回调(true);
$(“#gti modal”).hide();
});
$(“#gti模态btn编号”)。单击(函数(){
回调(假);
$(“#gti modal”).hide();
});
$(“#gti模式btn关闭”)。单击(函数(){
回调(假);
$(“#gti modal”).hide();
});
}
函数modalAsk(msg、oldVal、newVal){
$('.modal')。附加到($('body');
$(“#gti模态msg”)[0]。innerHTML=“”+msg+”;
$(“#gti model”).show();
ModalConfig(功能(确认){
如果(确认){
奥尔德瓦尔=纽瓦尔
警报(“更改”)
}否则{
警报('无更改')
}
});
}
函数funConfirmFields(字段名、oldVal、newVal){
如果(newVal!==“”){
if(newVal!==oldVal){
if(modalAsk('Warning!
Field:'+fieldName.toUpperCase()++'”
旧值:'+oldVal+'
新值:'+newVal+'

更改为新值?')){ newVal=oldVal } } }否则{ newVal=oldVal; } 返回纽瓦尔 } $(文档).ready(函数(){ $(“#txtName”)[0]。value=funConfirmFields('Name',$(“#txtName”)[0]。value,“b”; $(“#txtDoc”)[0]。value=funConfirmFields('Doc',$(“#txtDoc”)[0]。value,“2222”); $(“#txtCell”)[0]。value=funConfirmFields('Cell',$(“#txtCell”)[0]。value,“456”); });

×

MyModal

对 不
我认为
引导模式
的行为不像
确认窗口
,因此我可以转到,但我更喜欢这样动态构建它

这是我的结果:

函数addModal(id,msg,callback){
html='';
html+='';
html+='';
html+='';
html+='×';
html+=‘GTI’;
html+='';
html+='';
html+=''+msg+''
html+='';
html+='';
html+=‘是’;
html+=‘否’;
html+='';//内容
html+='';//对话框
html+='';//页脚
html+='';//modalWindow
$('body').append(html);
$(“#gti模态-”+id).show();
$(“#gti modal-”+id).on('hidden.bs.modal',函数(e){
$(this.remove();
});
$(“#gti模态btn是-”+id)。单击(函数(){
回调(true);
$(“#gti模态-”+id).hide();
});
$(“#gti模态btn编号-”+id)。单击(函数(){
回调(假);
$(“#gti模态-”+id).hide();
});
$(“#gti模式btn关闭-”)。单击(函数(){
回调(假);
$(“#gti模态-”+id).hide();
});
}
函数askModal(id、msg、inputFiel、newValue){
addModal(id、msg、函数(确认){
inputFiel.val(确认?新值:inputFiel.val());
});
}
函数funConfirmField(id,inputFiel,newValue){
if(newValue!==“”&(newValue!==inputFiel.val()){
askModal(id,'Warning!
字段:'+id.toUpperCase()+'
新值:'+newValue+'
旧值:'+inputFiel.val()+'

更改为新值?',inputFiel,newValue); } } $(文档).ready(函数(){ funConfirmField('Name',$('#Name'),'jonh'); funConfirmField('Doc',$('#Doc'),'222'); funConfirmField('Cell',$('#Cell'),'508'); });