[英]jquery slider Uncaught TypeError: undefined is not a function
Running into an issue using jQuery .slider()
. 使用jQuery
.slider()
遇到问题。 I'm using the most recent version of jQuery downloaded from here (using the UI and jQuery library from that download). 我正在使用从此处下载的最新版本的jQuery(使用该下载中的UI和jQuery库)。
When the page loads the line that attempts to bind the slider to the div receives the following error 当页面加载试图将滑块绑定到div的行时,收到以下错误
_Layout.cshtml _Layout.cshtml
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jsMVC")
@Scripts.Render("~/bundles/BackboneApps")
</head>
BundleCollections 捆绑收藏
bundles.Add(new ScriptBundle("~/bundles/BackboneApps").Include(
"~/Scripts/SliderApp.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui.js"));
bundles.Add(new ScriptBundle("~/bundles/jsMVC").Include(
"~/Scripts/underscore.js",
"~/Scripts/backbone.js"));
Rendered HTML 呈现的HTML
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title></title>
<link href="/Content/site.css" rel="stylesheet"/>
<script src="/Scripts/jquery.js"></script>
<script src="/Scripts/jquery-ui.js"></script>
<script src="/Scripts/underscore.js"></script>
<script src="/Scripts/backbone.js"></script>
<script src="/Scripts/SliderApp.js"></script>
</head>
SliderApp.js SliderApp.js
$(document).ready(function () {
// Initialize jquery slider
$("#slider").slider();
.
.
});
Index.cshtml Index.cshtml
<!-- "slider" is a jquery slider -->
<div id="slider"></div>
<!-- "sliderVal" displays the slider's position. It receives the value via model. -->
<input type="text" id="sliderVal" value="0"/>
This was happening because, at the bottom of the page, a random 发生这种情况是因为,在页面底部,随机
@Scripts.Render("~/bundles/jquery")
was entered. 已输入。 Since the jQuery library was loading twice the
ui
from above was blown away. 由于jQuery库加载了两次,因此
ui
从上面被吹走了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.