开发者

can't get jquery livequery to with an update panel

I have some basic html inside an asp.net update panel. Using livequery, I set up autocomplete, blur and keydown events so that they all continue to be wired up after the update panel does a partial page load. When the page initially loads, all the events work fine but after the update panel does a partial page reload, none of the events wired up with livequery continue to work. Are there known issues with livequery and update panels?

Html:

<asp:UpdatePanel ID="upData" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:DataList ID="dlData" runat="server"
            DataSource='<%# this.Data %>' DataKeyField="ID">
            <ItemTemplate>
                <table>
                    <tr>
                        <th class="required">Location</th>
                        <td><asp:TextBox ID="txtFromLocation" MaxLength="10" CssClass="searchlocation fromlocation required" runat="server" Text='<%# Eval("FromLocation")%>'/><asp:RequiredFieldValidator ID="rvalFromLocation" runat="server"
            ControlToValidate="txtFromLocation" ValidationGroup="leg">*</asp:RequiredFieldValidator></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>
     </ContentTemplate> </asp:UpdatePanel>

And then I have my javascript. Normally it has a bunch of other code, but I can reduce it down to this and still have the problem:

$(document).ready(function() {
    $(".searchlocation").livequery(function() {                       
        $(this).keydown开发者_如何学运维(function(event) {alert('test');});   

        ...

        $(this).autocomplete(...);
    });
});


If you're on jQuery 1.3+, you can use .live() without any plugin, like this:

$(function() {
  $('.searchlocation').live('keydown', function(event) {
    alert('test');
  });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜