jQuery Autocomplete plugin not working with jQuery 1.4.1
I've been using the JQuery Autocomplete plugin with JQuery version 1.3.2, and it has been working great. I recently updated JQuery in my project to version 1.4.2, and the Autocomplete plugin is now broken. The JQuery code to add items to a textbox on my web page doesn't seem to be getting called at all. Does anyone know if the JQuery Autocomplete plugin is incompatible with JQuery version 1.4.2, and if there is a fix for this problem? Here is some sample code I've built in an ASP.Net web site (which works fine if I change the JQuery file to jquery-1.3.2.js, but nothing happens using jquery-1.4.2.js):
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/jquery.autocomplete.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
$(':input:text:id$=sapleUser').autocomplete(data);
});
</script>
</head>
<body>
<form id="form1" runat="server">
API Reference: <input id="sapleUser" autocomplete="off" type="text" runat="server" /> (try "C" or "E")
</for开发者_运维问答m>
</body>
</html>
It turned out that the Autocomplete plugin is compatible with JQuery ver 1.4.1 and 1.4.2. The problem was caused by my JQuery selector: $(':input:text:id$=sapleUser'), which appears not to be compatible with the 1.4.x versions of JQuery. I modified the selector to: $('input[id$=sapleUser]'), and it is now working again.
精彩评论