0

I need a solution for the following problem.

I am using jquery odd selector to add a css to every odd item in a asp:repeater.

$(".item:odd").attr("class", "item odd");

After I do an ajax call (from updatepanel) to go to the next page in the repeater the classes aren't added to the items on the next page.

$(document).ajaxComplete doesn't seem to do the trick.

Any ideas?

Many thanks,

Arnoud

4

2 回答 2

0

Just add

$(".item:odd").attr("class", "item odd");

Inside the success callback for your ajax request

于 2011-11-02T14:25:39.833 回答
0

一种可能的解决方案是添加到页面:

<script type="text/javascript">
    window.onload = function() {
      Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
    }

    function endRequestHandler(sender, args) {
        $(".item:odd").attr("class", "item odd");
    }
</script>

endRequestHandler 的内容将在每个 AJAX 请求之后运行。

您可能还需要向页面添加 ScriptManager:

<asp:ScriptManager ID="ScriptManager1" runat="server">
于 2011-11-02T14:51:02.167 回答