I have two JavaScript files:
- scripts.js - does all the
onload
setup work and attaches event handlers to controls - map.js - defines a
MAP
widget
When the document loads, scripts.js initialises a MAP
object by loading map.js and calling initMap
:
/** ON DOCUMENT LOAD **/
$(document).ready(function() {
$.getScript('lib/map.js', function() {
/** Generate a new map **/
MAP = initMap(10,mapDefault);
});
There is a button that allows a user to regenerate the map, which also calls initMap
. For example:
$('input#regenerateButton').click(function() {
$.getScript('lib/map.js', function() {
MAP = initMap($('input#mapSize').val(),mapDefault);
});
});
Do I need to re-load the script map.js again, since it will likely have already been loaded at this point?
This question has been asked previously, however I don't believe the part about multiple calls to $.getScript
was answered.