jQuery 对话框:未正确运行其他客户端验证?
根据我对 JQuery Dialog 的使用,我发现对话框内的元素很难正确“加载”。
场景:
1)我单击按钮加载对话框。
2) 该对话框有一个保存按钮、一个关闭按钮和 2 个文本框,其中 1 个链接到 Jquery 的日期选择器。另一个是[必需]的文本框。
从保存按钮,我有以下行为:
$.validator.unobtrusive.parse("#EventManage");
似乎:
1)日期选择器不能立即工作。相反,我必须关闭该对话框,然后打开它几次才能使其正常工作。
2)如果我单击“保存”,验证有时根本不起作用。有时需要关闭几次对话框才能使其正常工作。
3) 如果验证通过显示错误起作用,则日期选择器不再起作用。
4)第一次运行时,对话框似乎需要很长时间才能加载。
有什么想法为什么这种行为如此奇怪吗?
编辑
Firebug 向我展示内容:-
日期时间:- i is undefined function(f){f=a(f.target).closest("but...d("a").removeClass("ui-state-hover");
按钮无法通过任何验证也不提交表格:- $.validator.unobtrusive $.validator.unobtrusive.parse("#EventManage");
单击任意文本框,然后单击其他位置:- c.validator.methods[e] 未定义 [中断此错误]prepareElement:function(a){this.reset(...检查元素时发生“+
编辑
似乎原因是由于 js 文件的双重引用,
这些功能似乎工作正常。但是,我遇到了显示但根本无法选择任何日期的情况:)
编辑 3
我想我 。发现问题。我有一个 datepicker setDefaults 在我的主布局中将日期设置为 maxdate:0 现在我将对话框的部分 cshtml 中的 datepicker 设置为 minDate: 1. 如何覆盖布局的 datepicker
?已解决:只需设置 maxDate: null 即可。
From what I have played around with JQuery Dialog, I made an observation that the elements inside the dialog have some hard time trying to 'load' properly.
Scenario:
1) I clicked a button to load a dialog.
2) The dialog has a save button, a close button, and 2 textboxes, 1 which is linked to Jquery's datepicker. Another is a textbox that is [Required].
From the save button, I have the behavior of:
$.validator.unobtrusive.parse("#EventManage");
It seems that:
1) The datepicker doesn't work instantly. Instead I have to close the dialog, and open it a few times in order to make it work.
2) If I click save, and the validation sometimes doesn't work at all. It takes a close of the dialog a few times to make it work as well, sometimes.
3) If that validation works by showing an error, the datepicker no longer works.
4) on the first run, the dialog seems to take a pretty long time to load.
Any ideas why is the behavior so strange?
EDIT
Firebug showing me stuff:-
DateTime:-
i is undefined function(f){f=a(f.target).closest("but...d("a").removeClass("ui-state-hover");
Button not able to pass through any validation nor submit form:-
$.validator.unobtrusive $.validator.unobtrusive.parse("#EventManage");
Clicking any textbox and then clicking elsewhere:-
c.validator.methods[e] is undefined [Break On This Error] prepareElement:function(a){this.reset(...tion occured when checking element "+
EDIT
Seems like the cause is due to dual referencing of the js files.
The features seem to working properly. However, I am encountering the datepicker showing but unable to pick any date at all. Any ideas? :)
EDIT 3
I think I found the issue. I have a datepicker setDefaults that sets the date to maxdate:0 in my main layout. Now i am setting the datepicker within the dialog's partial cshtml to be minDate: 1. how do i override the layout's datepicker?
SOLVED: just need to set maxDate: null. phew!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次更新 DOM 并替换日期选择器的相应输入字段时,与重新附加不显眼的客户端验证的方式相同,您应该重新附加日期选择器:
$('.datepicker').datepicker();
。Everytime you update the DOM and replace the corresponding input field of the datepicker, the same way you are reattaching the unobtrusive client side validation, you should re-attach the datepicker:
$('.datepicker').datepicker();
.