【发布时间】:2014-07-20 08:31:26
【问题描述】:
我在基本使用 ASP.NET MVC5 中的 JQuery UI 库时遇到了困难。虽然我使用它的自动完成没有问题,但每当我尝试使用对话框时,我都会在 .dialog 行上收到“未定义不是函数”错误。鉴于我正在使用自动完成功能,它会建议加载 UI 脚本。
为了进一步检查,我将其全部剥离,因此它只是基本 MVC 模板的索引页面上的对话框,其中最简单的更改是 html、对话框的 div 和打开按钮它,对于脚本,以正确的顺序链接到外部库 - JQuery 然后 JQuery UI(同时取出了 jquery 捆绑)。下面是生成的页面的页面源,它仍然会产生相同的错误。
知道我做错了什么吗?
提前致谢,
罗伯特
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page - My ASP.NET Application</title>
<link href="/Content/css?v=m8KdMFOCcNeZrATLbCQ_9gxex1_Ma7rE5iJzJXojUIk1" rel="stylesheet"/>
<script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.js"></script>
<script>
$(document).ready(function () {
('#dialogA').dialog();
});
</script>
<script>
$(document).ready(function () {
$('#btnDialog').button().click(function (e) {
$('#dialogA').dialog("open");
})
});
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Application name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/Home/About">About</a></li>
<li><a href="/Home/Contact">Contact</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/Account/Register" id="registerLink">Register</a></li>
<li><a href="/Account/Login" id="loginLink">Log in</a></li>
</ul>
</div>
</div>
</div>
<div id="dialogA">ttttt</div>
<input type="button" value="dialogbox" id="btnDialog" />
<div class="container body-content">
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
<h2>Getting started</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p>
</div>
<div class="col-md-4">
<h2>Get more libraries</h2>
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a></p>
</div>
<div class="col-md-4">
<h2>Web Hosting</h2>
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more »</a></p>
</div>
</div>
<hr />
<footer>
<p>© 2014 - My ASP.NET Application</p>
</footer>
</div>
<script src="/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1"></script>
<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Chrome","requestId":"010dfa370b8b4623bca1627473c2aaa0"}
</script>
<script type="text/javascript" src="http://localhost:43955/192d8c642ad44cee87f18b841afbf972/browserLink" async="async"></script>
<!-- End Browser Link -->
</body>
</html>
【问题讨论】:
-
错字:您在
('#dialogA').dialog()之前缺少$。 -
谢谢!凝视着森林,错过了我面前的那棵树。
标签: jquery jquery-ui jquery-ui-dialog