AnsweredAssumed Answered

Parsing Custom Widget

Question asked by andrewjwhittaker on Dec 1, 2016

I have created a simple widget that basically wraps the esri/Map and adds a left pane with a splitter and ExpandoPane.  I want to use the widget in an MVC app.  The problem that I am seeing is that I must set parseOnLoad to true in dojoConfig AND I must call the parse() function from dojo/parser.  If I do only one of those methods, the BorderContainer, ExpandoPane, and other layout controls do not get displayed.  I suppose because they aren't getting parsed. What am I doing wrong here?  For reference, the custom widget is called widget.RoutingMap.  It's hard to read the code below.  I've attached the MVC project in the file "".  Thanks!


Here's my MVC View:

ViewBag.Title = "Map";

@section Styles {
<link rel="stylesheet" href="" type="text/css" />
<link rel="stylesheet" href="" type="text/css" />
<link rel="stylesheet" href="" type="text/css" />
<style type="text/css">
#map {
height: 100%;
padding: 0;
margin: 0;

#mainBorderContainer {
margin-top: 52px;

body {
background-color: #FFF;
overflow: hidden;
font-family: "Trebuchet MS";

#map {
width: 100%;
height: 100%;
border: solid 2px #4682b4;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;

.bodyContainerPadBottom {
height: 100%;
margin: 0;
padding-bottom: 52px;

/* Extending Esri styles */
.dojoxExpandoTitle {
margin-top: 1px;
margin-bottom: 1px;
-moz-border-radius: 14px;
-webkit-border-radius: 14px;
border-radius: 14px;

/* Remove padding in ContentPane */
.claro .dijitContentPane {
padding: 0px;
/*overflow:auto;overflow:auto causes both horizontal and vertical scrollbars. We never want horizonal but might need vertical*/


<div data-dojo-type="widget.RoutingMap"></div>


@section scripts {
<script type="text/javascript">
$("#bodyContainer").attr("class", "bodyContainerPadBottom");
$("body").attr("class", "claro");
<script type="text/javascript">
var path = '';
var dojoConfig = {
async: true,
parseOnLoad: true,
tlmSiblingOfDojo: false,
isDebug: true,
packages: [
name: "widget",
location: path + "/_Map/js/widget"
name: "js",
location: path + "/_Map/js"

<script src=""></script>

<script type="text/javascript">
function (RoutingMap, parser) {



Here's my custom widget:


<div style="width: 100%; height: 100%">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:false, liveSplitters:true" id="mainBorderContainer">
<div id="leftPane" data-dojo-type="dojox/layout/ExpandoPane" data-dojo-props="title:'Options', maxWidth:300, splitter:true, region:'leading', easeIn:'easing.linear', easeOut:'easing.linear'" style="width: 300px; background: #fafafa;">
<div data-dojo-type="dijit/layout/AccordionContainer">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Directions'"></div>
<div id="mapCp" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true, region:'center'">
<div id="map">



// dojo core libs

// dojo dijits

// Site specific
// Config, enums

// dojo

// Esri classes

], function (declare, _WidgetBase, _TemplatedMixin, appConfig, mapTemplate, Map) {
var RoutingMap = declare(
[_WidgetBase, _TemplatedMixin],
templateString: mapTemplate,
baseClass: "routingMapWidget",

postCreate: function () {
console.log("Map postCreate called");

startup: function () {
console.log("RoutingMap startup called");

initMap: function () {
try {
console.log("Creating map"); = new Map("map", {
   basemap: "streets",
   showLabels: true,
   center: [-79, 35],
   zoom: 7,

} catch (e) {
console.log("***ERROR creating map: " + e.message);


return RoutingMap;