Jquery plugins Jquery对话框问题
大家好 我正在开发一个MVC应用程序,我想使用Jquery对话框。 我有以下情况: 我有Telerik树视图,当我单击任何节点时,我希望对话框打开并显示有关该节点的信息。 首先,我添加以下脚本来初始化对话框:Jquery plugins Jquery对话框问题,jquery-plugins,Jquery Plugins,大家好 我正在开发一个MVC应用程序,我想使用Jquery对话框。 我有以下情况: 我有Telerik树视图,当我单击任何节点时,我希望对话框打开并显示有关该节点的信息。 首先,我添加以下脚本来初始化对话框: $(document).ready(function () { $("#dialog").dialog("destroy"); $("#dialog-form").dialog({ autoOpen: false,
$(document).ready(function () {
$("#dialog").dialog("destroy");
$("#dialog-form").dialog({
autoOpen: false,
height: 500,
width: 500,
modal: true,
buttons: {
Cancel: function () {
$(this).dialog('close');
}
}
});
});
然后在OnSelect(Telerik的客户端事件)中编写以下代码
$('#对话框形式')。对话框('open');
$('#对话框形式')。加载('');
在我的母版页中,我添加了使模式工作如下所需的脚本文件:
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.dialog.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.core.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.widget.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.button.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.draggable.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.position.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.resizable.js") %>"></script>
<% Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
.Add("jquery-1.4.2.js")
.Add("jquery.ui.core.js")
.Add("jquery.ui.widget.js")
.Add("jquery.ui.mouse.js")
.Add("jquery.ui.draggable.js")
.Add("jquery.ui.button.js")
.Add("jquery.ui.resizable.js")
.Add("jquery.ui.dialog.js")
.Add("jquery.ui.position.js")
当我点击树的节点时,什么也没有发生,chrome开发者工具显示以下错误:
未捕获的TypeError:对象#没有方法“dialog”
似乎有一个脚本注册错误或类似的事情
有关此功能的任何帮助您需要调整依赖项顺序,使其正确,它应该是:
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.core.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.widget.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.mouse.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.draggable.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.button.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.position.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.resizable.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.dialog.js") %>"></script>
您可以在此处将库作为单个文件下载:
或者来自CDN,例如,来自谷歌的最新(截至回答时):
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
好处(它们非常类似于从CDN中包含jQuery本身的好处)。问题解决了。。。
当您想在视图中使用Telerik组件时,需要向脚本管理器注册脚本,如下所示:
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.dialog.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.core.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.widget.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.button.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.draggable.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.position.js") %>"></script>
<script type="text/javascript" src="<%: Url.Content("~/Scripts/jquery.ui.resizable.js") %>"></script>
<% Html.Telerik().ScriptRegistrar().DefaultGroup(group => group
.Add("jquery-1.4.2.js")
.Add("jquery.ui.core.js")
.Add("jquery.ui.widget.js")
.Add("jquery.ui.mouse.js")
.Add("jquery.ui.draggable.js")
.Add("jquery.ui.button.js")
.Add("jquery.ui.resizable.js")
.Add("jquery.ui.dialog.js")
.Add("jquery.ui.position.js")
组
.Add(“jquery-1.4.2.js”)
.Add(“jquery.ui.core.js”)
.Add(“jquery.ui.widget.js”)
.Add(“jquery.ui.mouse.js”)
.Add(“jquery.ui.draggable.js”)
.Add(“jquery.ui.button.js”)
.Add(“jquery.ui.resizeable.js”)
.Add(“jquery.ui.dialog.js”)
.Add(“jquery.ui.position.js”)
))%>
关于@Light-如果这些脚本不在正确的目录中,那么在页面启动时应该会出现错误,您的控制台会怎么说?您应该会收到JavaScript错误或404。我确信我的脚本位于正确的目录中。。控制台除了uncaughtypeerror外什么也没说:Object#没有方法'dialog'@Light-只是为了好玩,如果你使用上面的谷歌CDN版本,你有什么问题吗?如果您仍然有问题…请确保您没有在页面中包含两次jQuery,如果以后包含它,它将覆盖
$
,删除其上的$.ui
方法。Nick我无法使用google CDN进行google限制。。。我仍然不知道这个对话是怎么回事