That makes a little sense, here's an example of my concern:
My index page loads a page using jquery into a div element on the page -the page being loaded into the div contains this code:
Code:
<script type="text/javascript">
function editTerritory(id){
$('#'+id).load('modules/sales/list/territory_list.edit.php?id='+id,function(){
$('.editRow').hide();
});
}
function deleteTerritory(id){
$.load('modules/sales/list/territory_list.delete.php?id='+id,function(){
$('#'+id).remove();
});
}
$(document).ready(function(){
$('#editTerritoryForm').ajaxForm(function(){
reloadTerritory();
});
});
function reloadTerritory(){
$('#salesContent').load('modules/sales/list/territory_list.php');
}
</script>
Then using the menu bar on the index page, i click a link to load a different page into the same div element (replacing it with the new html), the new page contains this code:
Code:
<script type="text/javascript">
$(document).ready(function(){
$('#searchSales').keyup(function(){
$('#searchResult').html('<img src="images/loading2.gif" />').load('modules/sales/main.search_sales.php?search='+this.value);
});
});
function viewFile(fileId){
$('#salesContent').load('modules/sales/file/view_file.php?id='+fileId);
}
</script>
Now when i've loaded completely new content into this div element on the page, i can still call javascript functions from the previous content that was loaded into this same div.
My question is: How do i go about clearing out the 'javascript event buffer' between pages to prevent the uneccesarry build up of javascript code in the DOM or event buffer?
Bookmarks