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

查看:22
本文介绍了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 :

Uncaught TypeError: Object # has no method 'dialog'

Uncaught TypeError: Object # has no method 'dialog'

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

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

对此有任何帮助

推荐答案

问题解决了...当你想在你的视图中使用 Telerik 组件时,你需要像这样使用脚本管理器注册你的脚本:

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天全站免登陆