Is there a better way to load scripts into the div on the menu item click and on click of another menu item remove the previous scripts and load a fresh scripts from the current menu item clicked?
Script i use to load the div #content:
$('.nav-button').on('click', function(e){
e
.preventDefault();
$
('#content').load('../scripts/loader.php');
$
('#content').load($(this).attr('href'));
});
sample1.php page i load in to the div on menu-item1 clicked:
<div id='datagrid'>
<input></input>
<input></input>
<input></input>
</div>
<script type='text/javascript' src='scripts/menu-item1/data_script.js'></script>
sample2.php page i load in to the div on menu-item2 clicked:
<div id='datagrid'>
<input></input>
<input></input>
<input></input>
</div>
<script type='text/javascript' src='scripts/menu-item2/data_script.js'></script>