jqBootstrapValidation不是一个函数 [英] jqBootstrapValidation is not a function
问题描述
我有一个标准的.NET 4.5 Webforms应用程序.但是,只要我从 http://reactiveraven.github.io/jqBootstrapValidation/中加入jqBootstrapValidation,得到错误:
I have a standard .NET 4.5 Webforms application. However as soon as I include the jqBootstrapValidation from http://reactiveraven.github.io/jqBootstrapValidation/ I get the error:
jqBootstrapValidation is not a function
在Firebug控制台中
.我该如何追踪呢?我包括了网站管理员的相关部分:
in the Firebug console. How do I track this down? I include the relevant sections of my site master:
<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>
,然后在结束body标签之前:
and then before the closing body tag:
</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中注册捆绑包的相关代码....
Below is the relevant code from App_Start registering the bundles....
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-*"));
}
}
我在这里缺少什么?如何解决?诊断这类不是功能"问题.
What am I missing here and how do I fix it? Diagnose these kinds of "not a function" issues.
如果我没有受 http://amanek.com/building-data-annotations-validator-control-with-client-side-validation/
但是我仍然看不到这会对皮肤产生什么影响,因为在皮肤下使用纯JS.
But I still don't see how this would be affecting things as that is using pure JS under the skin.
推荐答案
我得出结论,在某些情况下,Unobtrusive验证是在jQuery中两次添加了jQuery,并且在页面的另一点添加了
I worked out that Unobtrusive validation was adding in jQuery twice and at a different point in the page under some circumstances.
由于我没有使用非侵入式验证,因此我通过以下方式禁用了它:
As I am not using unobtrusive validation I disabled it with:
<appSettings xdt:Transform="Replace">
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
这篇关于jqBootstrapValidation不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!