getSript adds handler several times at the same object

I have 2 divs, they have multiples elements and each element has options(events). In the first div, each element has a button that load, in the second div, the children elements. Those children have a edit button that opens a dialog where the user can edit.

Here is the script:

$("#Content").load("elements.php?id=5", function(){
    $.ajaxSetup({cache: true});
    $.getScript("../js/elements.js", function(){
        $.ajaxSetup({cache: false});
    });
})

The problem is: When I load #Content with its script, it`s works good only in the first time, it opens one dialog box, but if I load twice, it opens two dialog boxes, and three, etc.

How do I delete the last script I loaded?

Answers


Are there any bindings? any live, etc? I am not sure if its your current code that is causing this issue or the elements.js being that I dont know what is inside of it. I do recommend checking out Jquery stopImmediatePropagation(). I hope this can put you on the right path.


Need Your Help

get pixel from bitmap

javascript image canvas bitmap pixel

I need to process pixeldata from a 1000x1000px *.bmp image (~1MiB) in javascript

How to jQuery.post() an array to PHP

php jquery

After searching through so many SO questions, I can't seem to find a solution to my problem. I'm have no end of trouble trying to figure it out.

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.