jquery function inside pageload function fires multiple times

I have a small jquery function that opens a popup window.

As my site is asp.net based and uses update panels, I place the function inside of the ajax pageLoad() function, to ensure it works after each postback.

I'm developing a new page with a number of update panels. If, after I've made several asynch postbacks, I then click on the hyperlink with the popup, the function seems to fire once for each postback that has occurred.

Here's the function:

function pageLoad() {
    $("a.popup").click(function (e) {
        if (e.preventDefault) {
            e.preventDefault();
        }
        else {
            e.returnValue = false;
        }
        window.open(this.href, this.target, 'menubar=0, toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, width=1010, height=640, left=50, top=50');
    }
}

I'm at a loss to how to stop this happening. Any advice?

Answers


The event handler is getting re-bound every time the page load happens. Try this:

$("a.popup").unbind('click').click(function (e) {

Need Your Help

Eclipse from ADT bundle crashes in Ubuntu 14.04

android eclipse ubuntu-14.04

Whenever there is an auto complete window, eclipse crashes. I searched the internet and found out that putting " -Dorg.eclipse.swt.browser.DefaultType=mozilla " this line at the end of eclipse.ini ...

Do we use RPC or SSH for inter process communication in hadoop?

hadoop ssh rpc hadoop2

While reading fourth chapter of the Definitive Guide for Hadoop book, I found following sentences :