在重新加载UpdatePanel时重新连接由jQuery连接的客户端事件

时间:2022-08-25 16:51:30

I have a repeater in an updatepanel, in the repeater there are several panels. The panels are different in ways, but they have one common css class, so I wire their onclick, onmouseover and onmouseout event with jQuery on the $(document).ready

我在更新面板中有一个中继器,在中继器中有几个面板。这些面板的方式不同,但是它们有一个共同的css类,所以我在$(document).ready上用jQuery连接onclick,onmouseover和onmouseout事件。

But after a partial postback of the updatepanel update these wires are lost and I cant find a place to put these wires back in.

但在更新面板更新的部分回发后,这些线路丢失了,我找不到放回这些线路的地方。

$(document).ready(function () {
    $(".actionicon_normal").click(function () {
        ClickActionIcon($(this));
    });
    $(".actionicon_normal").hover(function () {
        HoverActionIcon($(this));
    }, function () {
        OutActionIcon($(this));
    });
    $(".actionicon_normal").each(function (i) {
        var chk = $(this).find("input");
        var backpos = $(this).css("background-position").split(" ");
        if (chk.attr("checked")) {
            $(this).css("background-position", backpos[0] + " -" + $(this).height() + "px");
        }
    });
})

as you can see I modify the background position in $(".actionicon_normal").each. I need a place to run a the same after the updatepanel is updated. I tried to experiment with .ajaxComplete, but was unable to find a proper solution.

如你所见,我修改了$(“。actionicon_normal”)中的背景位置。更新updatepanel后,我需要一个地方运行相同的地方。我尝试使用.ajaxComplete进行实验,但无法找到合适的解决方案。

Another way would be to wire these in the codebehind, but I cannot get a hold of all the actionicons, as the ItemDataBind only urns on first load, plus even in ItemCreated I'm not able to get a hold of all these divs having one same css class, plus there is a CheckBox in the div which I need to check for the checked value and I was not able to do that either. So if the server side is a better way, I would need a lot of help on that.

另一种方法是在代码隐藏中连接这些,但是我无法控制所有的动作,因为ItemDataBind只在第一次加载时输入,加上即使在ItemCreated中我也无法控制所有这些具有一个的div相同的css类,加上div中有一个CheckBox,我需要检查检查值,我也无法做到。因此,如果服务器端是更好的方式,我需要很多帮助。

1 个解决方案

#1


1  

This page might help: http://msdn.microsoft.com/en-us/library/bb386417.aspx

此页面可能有所帮助:http://msdn.microsoft.com/en-us/library/bb386417.aspx

The following method is triggered by the Script manager every time the page is loaded, you are only concerned about partial postbacks so it also check this

每次加载页面时,脚本管理器都会触发以下方法,您只关心部分回发,所以它也会检查这个

function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {

        }
    }

#1


1  

This page might help: http://msdn.microsoft.com/en-us/library/bb386417.aspx

此页面可能有所帮助:http://msdn.microsoft.com/en-us/library/bb386417.aspx

The following method is triggered by the Script manager every time the page is loaded, you are only concerned about partial postbacks so it also check this

每次加载页面时,脚本管理器都会触发以下方法,您只关心部分回发,所以它也会检查这个

function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {

        }
    }