I have a header.js that includes in its ready section the following:
var auto_refresh = setInterval(function () {
var theToken = $('#token').text();
$('#error-div').text('');
$('#load_me').load("http://localhost:8080/sc_demo/tasklist.jsp?app=Home&process=tasklist&userToken="+theToken
).fadeIn("slow");
}, 30000); // autorefresh the content of the div after every 3000 milliseconds(30sec)
Now, the page it loads, "tasklist.jsp" gets loaded into a div on the current page and should be refreshed every 30 seconds. The tasklist.jsp has "click" events that need to be serviced and are handled by click events in header.js. In order for those to work, even though tasklist.jsp is getting loaded into a page that already has header.js included, I have to include header.js in the tasklist.jsp. This however, leads to cascading reloads. How do I prevent this? Is it really impossible to try to have decent code reuse? Why should I need to include the header.js if it should already be in the page I loading my portion into?