绕过“onblur”在 jquery 对话框中取消和 (x) 按钮
我使用 jquery 对话框来显示我的表单,并在表单上使用 MVC 3 不显眼的客户端验证。目前,如果用户单击“取消”按钮和关闭图标:(x) 按钮,将显示验证消息。
这很奇怪,因为用户可能会意外打开一个对话框并只想关闭它,但这些 [必填] 字段旁边显示的验证消息有点烦人又有趣。
我不知道如何“控制”这两个按钮。我也在这里包含了在对话框中初始化按钮的脚本:
//Load food form into dialog
var controllerUrl = '/Stock/GetFoodForm';
var $createdialog = $('#createfooddialog').load(controllerUrl).dialog({
autoOpen: false,
title: 'Create Food',
modal: true,
width: 'auto'
});
$createdialog.dialog("option", "buttons", {
"Cancel": function () {
//alert('Cancel');
$createdialog.dialog('close');
},
"Submit": function () {
submitForm();
}
});
希望可以在这里获得一些帮助...欣赏它...
I am using jquery dialog to display my form and I use MVC 3 unobtrusive client side validation on the form. Currently if user click on the Cancel button and the close icon: (x) button, the validation message will be shown.
It is weird since user might accidentally open a dialog and want to just close it, but the validation message shown beside those [Required] field is kind of annoying and funny.
I got no idea how to "control" this 2 buttons. I include the script which I initialize the buttons in my dialog here too:
//Load food form into dialog
var controllerUrl = '/Stock/GetFoodForm';
var $createdialog = $('#createfooddialog').load(controllerUrl).dialog({
autoOpen: false,
title: 'Create Food',
modal: true,
width: 'auto'
});
$createdialog.dialog("option", "buttons", {
"Cancel": function () {
//alert('Cancel');
$createdialog.dialog('close');
},
"Submit": function () {
submitForm();
}
});
Hope can get some help here... Appreciate it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
#createfooddialog 是否位于表单标签之间?如果是这样,请尝试将其移出。
Is #createfooddialog located between your form tags? If so, try moving it out.
我现在取消了客户端验证的急切效果,因此单击提交后只有用户会看到该消息。我仍然找不到任何解决方案
I am now cancelled the eager effect of client side validation, so after click submit only user will see the message. I still cant find any solution for this yet