Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC4 Returning a different view not triggering javascript events
    primarykey
    data
    text
    <p>I am attempting an ASP.NET MVC4 page that collects data from a form submits that to a web service and returns a different view which renders a map based on the results from the web service. I'm running into a problem where the view that shows the results will not render any maps. I am new to jQuery/ASP.NET so maybe I am missing something obvious.</p> <p><strong>The controller piece:</strong></p> <pre><code>public ActionResult Project(MyProjectModel project) { //Make web service call using project model and create a result model ... var model = new ResultModel {Name=project.Name}; return View("Results", model); } </code></pre> <p><strong>The View:</strong></p> <pre><code>@model WebApp.Models.ResultModel @{ ViewBag.Title = "Results"; } &lt;link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/soria/soria.css"&gt; &lt;script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("esri.map"); dojo.declare("my.MapLayer", esri.layers.DynamicMapServiceLayer, { constructor: function () { this.initialExtent = this.fullExtent = new esri.geometry.Extent({ xmin: 143.834824, ymin: -43.648056, xmax: 148.47914, ymax: -39.57389, spatialReference: { wkid: 4326} }); this.spatialReference = new esri.SpatialReference({ wkid: 4326 }); this.loaded = true; this.onLoad(this); }, getImageUrl: function (extent, width, height, callback) { var params = { request: "GetMap", transparent: "true", format: "image/png", version: "1.1.0", layers: "ws:@Model.JobId", exceptions: "application/vnd.ogc.se_xml", //changing values bbox: extent.xmin + "," + extent.ymin + "," + extent.xmax + "," + extent.ymax, srs: "EPSG:" + extent.spatialReference.wkid, width: width, height: height }; callback("http://localhost:8080/geoserver/wms?" + dojo.objectToQuery(params)); } }) function init() { var map = new esri.Map("map"); map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer")); map.addLayer(new my.MapLayer()); } $('#output').live("pageshow", function () { alert('pageshow'); init(); }); $('#output').live("pagecreate", function () { alert('pagecreate'); }); $(document).ready(function () { alert('docready'); $("#output").live('pageshow', init); }); &lt;/script&gt; &lt;div data-role="page" data-theme="b" id="output"&gt; &lt;div data-role="content"&gt; &lt;div id="map" class="soria" style="position: relative; width: 100%; height: 300px; border: 2px solid #000;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The map will load if I type the URL directly in the browser, however whenever I try to return it with from another controller view, the javascript events will not trigger. Is this by design or am I abusing MVC / jQuery here? Thanks for any suggestions!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload