我已经尝试了多种方法来允许这个功能工作 - 引用各种jquery ......并且没有工作。谁能告诉我我做错了什么。我读了它的参考顺序......我试着改变它。我读了它的捆绑配置...我编辑了那个。我读了它的jquery版本..我改变了......我读了abt migrate ...那样做......似乎没什么用。我不明白我做错了什么。
修改 从头标记中删除了一些行。留下以下内容。但是.valid仍然无效..:
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - COMIS</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="~/Content/themes/base/jquery.ui.core.css" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet"
type="text/css" />
<script src="~/Scripts/jquery-1.11.1.js" type="text/javascript"></script>
<script src="~/Scripts/jquery-migrate-1.2.1.js" type="text/javascript"></script>
<script src="~/Scripts/datepicker.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/Scripts/buttons.js")
@Scripts.Render("~/Scripts/navigation.js")
功能
$(function () {
global.initButtons();
});
var global = {
initButtons: function () {
$('a.button.positive').click(function (e) {
e.preventDefault();
var parentForm = $(this).closest('form');
if (!parentForm.valid()) {
$("form").validate();
// global.flashMessage('Error validating these values', 'error');
}
else {
$(this).css(global.disableCss).unbind('click');
parentForm.submit();
}
});
},
disableCss: { opacity: 0.5, display: 'inline-block' }
};