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

Vertical Aligײment doesn't work XAML

c# xaml grid alignment center

I'm develope an app for Windows Store and I would like to know how can center it so it will be in the middle of the screen (I'm using XAML/C#), inluding all the content in it.

jquery form results are not showing. Is my code wrong?

javascript jquery css ajax output

I am having difficulty with my form. On one of my pages is a form. You enter info, click submit, and it returns with some result. Well, it is supposed to return with a result. It appears to do noth...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.