我有一个标准的.NET 4.5 Webforms应用程序。但是,一旦我包含了来自http://reactiveraven.github.io/jqBootstrapValidation/的http://reactiveraven.github.io/jqBootstrapValidation/,我就会得到错误:
jqBootstrapValidation is not a function在Firebug控制台中。我要怎么追踪这个?我包括我的网站管理员的相关部分:
<head runat="server">
<meta charset="utf-8" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"> </script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"> </script>
<script src="//raw.github.com/ReactiveRaven/jqBootstrapValidation/1.3.6/jqBootstrapValidation.js"></script>
</head>
<body data-spy="scroll" data-target="#NavbarLeft">
<form novalidate class="form-horizontal" runat="server">
<asp:ScriptManager runat="server" EnablePageMethods="True" EnableCdn="True">
<Scripts>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>然后在结束正文标记之前:
</form>
<%--//Comment this in once we can work out why it wont compile--%>
<script>
$(function () {
$("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
});
</script>
</body>
</html>下面是App_Start注册捆绑包的相关代码.
public class BundleConfig
{
public static void RegisterBundles(BundleCollection aBundles)
{
aBundles.Add(new ScriptBundle("~/Bundles/WebFormsJs").Include(
"~/Scripts/WebForms/WebForms.js",
"~/Scripts/WebForms/WebUIValidation.js",
"~/Scripts/WebForms/MenuStandards.js",
"~/Scripts/WebForms/Focus.js",
"~/Scripts/WebForms/GridView.js",
"~/Scripts/WebForms/DetailsView.js",
"~/Scripts/WebForms/TreeView.js",
"~/Scripts/WebForms/WebParts.js"));
aBundles.Add(new ScriptBundle("~/Bundles/MsAjaxJs").Include(
"~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));
// Use the Development version of Modernizr to develop with and learn from. Then, when you’re
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need
aBundles.Add(new ScriptBundle("~/Bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
}
}我在这里遗漏了什么,我该如何解决?诊断这类“非函数”问题。
如果我没有任何受http://amanek.com/building-data-annotations-validator-control-with-client-side-validation/保护的字段,错误就会消失。
但我仍然不知道这会如何影响事物,因为这是使用纯JS在皮肤下。
发布于 2013-11-21 10:46:40
我计算出,在某些情况下,在页面中的两次和不同的位置添加了两次不引人注意的验证。
由于我没有使用不显着的验证,所以我用以下方法禁用了它:
<appSettings xdt:Transform="Replace">
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>发布于 2013-11-20 05:14:47
你的剧本让我觉得很奇怪。例如,我认为:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>
实际上应该是:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>
将所有的包含更改为后一种格式,看看这是否有帮助。
https://stackoverflow.com/questions/20087885
复制相似问题