首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQueryUI Ajax.NET回发虫

jQueryUI Ajax.NET回发虫
EN

Stack Overflow用户
提问于 2010-05-11 01:23:41
回答 2查看 658关注 0票数 2

我有带有 ASP.NET页面的ASP.NET UpdatePanel和jQueryUI可下垂和可排序的组件。该页面在所有浏览器中运行良好,但在(IE8测试)中不工作。

在我尝试调用ASP.NET AJAX事件(通过在asp.net中按UpdatePanel按钮)之后,我的可排序列表在IE浏览器中停止正常工作,浏览器引发以下错误:

消息:未指定的错误。行: 145 Char: 186代码:0 URI:http://code.jquery.com/jquery-1.4.2.min.js

我发现问题是由第66行的代码引起的:

代码语言:javascript
复制
$("#droppable").droppable();

如果我将其注释掉,则可排序列表在ajax回发后可以正常工作。但这毫无意义。

有人知道会出什么问题吗?

谢谢。

我使用的是jQueryUI 1.8.1和jQuery 1.4.2

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-05-13 22:30:00

我相信这是JQuery中的一个bug --我认为有一个修复方法,您可以在这里重新定义偏移量函数,以便在IE下工作:

http://dev.jqueryui.com/ticket/4918

干杯

票数 1
EN

Stack Overflow用户

发布于 2010-05-14 18:30:17

解决方案

代码语言:javascript
复制
<%@ Page Language="C#" AutoEventWireup="true" %>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
        <style type="text/css">
                #sortable
                {
                        list-style-type: none;
                        margin: 0;
                        padding: 0;
                        border: solid 1px #999999;
                }
                #sortable li
                {
                        margin: 0.3em 0.3em 0.3em 0.3em;
                        padding-left: 1.5em;
                        font-size: 1em;
                        height: auto;
                        border: dotted 1px #999999;
                        background-color: #dddddd;
                }
                #sortable li:hover
                {
                        background-color: #aaaaaa;
                }
        </style>
</head>
<body>
        <form id="form1" runat="server">
                <asp:ScriptManager runat="server" ID="srptManager">
                        <Scripts>
                                <asp:ScriptReference Path="http://code.jquery.com/jquery-1.4.2.min.js" />
                                <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" />
                        </Scripts>
                </asp:ScriptManager>
                <asp:UpdatePanel ID="updPanel" runat="server">
                        <ContentTemplate>
                                <ul id="sortable">
                                        <li>Item 1</li>
                                        <li>Item 2</li>
                                        <li>Item 3</li>
                                        <li>Item 4</li>
                                        <li>Item 5</li>
                                </ul>
                                <div id="droppable" style="background-color: black">
                                        Drop Here</div>
                                <asp:Button runat="server" ID="btnAjaxRefresh" Text="Go" />
                        </ContentTemplate>
                </asp:UpdatePanel>
 
                <script type="text/javascript" language="javascript">
                        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                        // *******Solution Here*******
                        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
 
                        function EndRequestHandler(sender, args) {
                                if (args.get_error() == undefined) {
                                        jqueryStuff();
                                }
                        }
 
                        function BeginRequestHandler(sender, args) {
                                $("#sortable").sortable("destroy");
                                $("#droppable").droppable("destroy");
                        }
 
                        function jqueryStuff() {
                                $(document).ready(function() {
                                        $("#sortable").disableSelection();
                                        $("#sortable").sortable();
                                        // ******Problem at this line******
                                        $("#droppable").droppable();
                                });
                        }
 
                        jqueryStuff();
                </script>
        </form>
</body>
</html>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2807502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档