jQuery对话框问题 [英] Jquery Dialog Problem

查看:89
本文介绍了jQuery对话框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好 我正在开发MVC应用程序,并且我想使用Jquery对话框. 我有以下情况: 我有Telerik树视图,当我单击任何节点时,我希望对话框打开并显示有关此节点的信息. 首先,我添加以下脚本来初始化对话框:

Hi every body i am developing a MVC application, and i want to use Jquery dialog . i have the following scenario : I have Telerik tree view, and when i click on any node i want the dialog to open and display information about this node. First i add the following script to initialize the dialog :

    $(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的客户端事件)中编写了以下代码

then wrote the following code in OnSelect (client event of Telerik )

        $('#dialog-form').dialog('open');
        $('#dialog-form').load('<%= Url.Action("SomeAction", "SomeController") %>');

在我的母版页中,我添加了使模态工作像这样所必需的脚本文件:

in my master page i have added the script files that are necessary to make the modal work like this :

<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>

当我单击树的节点时,Chrome开发人员工具没有显示任何错误:

and when i click on the nodes of the tree nothing happed the chrome developer tools show the following error :

未捕获的TypeError:对象#没有方法'dialog'

Uncaught TypeError: Object # has no method 'dialog'

似乎脚本注册或类似的东西有错误

it seems that there is an error with script registration or some thing like that

对此有任何帮助

推荐答案

问题已解决... 当您想在视图中使用Telerik Components时,需要使用以下脚本管理器注册脚本:

Problem solved... when you want to use Telerik Components in your views, you need to register your scripts with script manager like this :

<% 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")

);
%>

);
%>

致谢

这篇关于jQuery对话框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆