In an effort to update a partial View containing an interactive world map, my objective is to refresh it with new data. I have a Controller action
public JavaScriptResult DynMap(int id, List<int> relevantCountries = null){}
This action returns the map data as JavaScriptResult
.
I am calling this Javascript in my Partial View "MapSite" using
<script src="/JS/DynMap/@ViewBag.GameRoomID"></script>
The Partial View "MapSite"
public ActionResult MapSite(int id)
{
ViewBag.GameRoomID = id;
return PartialView("MapSite");
}
This view is then displayed in my main page like this:
<td id="map">
@{Html.RenderAction("MapSite", "JS");}
</td>
Everything works perfectly fine! However, when I attempt to reload the MapSite at runtime with new values using: $('#map').load('/JS/MapSite/4')
(4 is static for testing purposes), the Partial View does not contain the DynMap Javascript.
Is this a bug? Is it not possible to load external Javascript in this way dynamically? Although the breakpoint inside the Controller DynMap method is hit, the map appears empty because the DynMap values are missing.