我有带有这 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行的代码引起的:
$("#droppable").droppable();如果我将其注释掉,则可排序列表在ajax回发后可以正常工作。但这毫无意义。
有人知道会出什么问题吗?
谢谢。
我使用的是jQueryUI 1.8.1和jQuery 1.4.2
发布于 2010-05-13 22:30:00
我相信这是JQuery中的一个bug --我认为有一个修复方法,您可以在这里重新定义偏移量函数,以便在IE下工作:
http://dev.jqueryui.com/ticket/4918
干杯
发布于 2010-05-14 18:30:17
解决方案
<%@ 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>
https://stackoverflow.com/questions/2807502
复制相似问题