views:

204

answers:

1

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(...);
    });
});
+1  A: 

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

$(function() {
  $('.searchlocation').live('keydown', function(event) {
    alert('test');
  });
});
Nick Craver
My example was simplified, in addition to keydown, I need to use autocomplete as well.
Jeremy
@Jeremy - Where is your jQuery code sitting, is it being reloaded in the update panel?
Nick Craver
@Nick,no it's all in a seperate js file referenced by a script tag in my page header.
Jeremy
@Jeremy - It sounds like there's a js error when the update panel comes back, can you check in firebug/chrome, or have a page I can get to?
Nick Craver