开发者

Run JQuery after Specific updatePanel fires

开发者 https://www.devze.com 2023-04-10 00:00 出处:网络
I have a script that runs once an update panel fires: Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

I have a script that runs once an update panel fires: Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function EndRequestHandler(sender, args) { initDropSearch(); } function initDropSearch() {

    var search = jQuery("#searchBar div.productSearchFilter");

    if (search.length > 0) {

        va开发者_Python百科r grid = search.find("table.gridView");

        if (search.next().val() != "open") {

            search.animate({
                height: ['toggle', 'easeOutBounce'],
                opacity: 'toggle'
            }, 1000)

            .next().val("open");

        } else {

            search.show();

        }
    }
}

Once the results of a search have loaded, the container drops down and bounces.

It works perfectly - that is until another update panel is triggered on the same page - in which case the search panel opens again.

What I need to do is only run the script when a specific updatePanel fires.

Is there a way to do this?


Do the sender or args contain data about the UpdatePanel that triggered the EndRequestHandler?

If so just check which one triggered it and only fire your code based on that.

function EndRequestHandler(sender, args) {
    if (((UpdatePanel)sender).ID == "UpdatePanel1") {
        initDropSearch(); 
    }
}
0

精彩评论

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