JavaScript API Scope from Web AppBuilder Widget.js

10-03-2017 03:12 PM
New Contributor

I'm new to customizing widgets and haven't been able to access some methods that are specific to the JavaScript API that according to a development summit session should be accessible.

I'm working on a custom widget that was created from the CustomWidget template directory.  For learning purposes I'm trying to simply show or hide a layer using the snippet below that was included in a developer summit session:

this.projectsLayer ='LayerName');;

This is contained within the onOpen attribute / event.

onOpen: function(){
this.projectsLayer ='LayerName');;


In the developer summit session it was stated that since this widget is inheriting from BaseWidget it should have access to the map instance.  When I run this application in Chrome the developer tools console shows the error: TypeError: Cannot read property 'show' of undefined. in the console displays the HTML of the map.  Trying or both trigger TypeError: or is not a function.

I'm unsure if these methods are outside the scope of BaseWidget or if I am somehow missing a reference.

The beginning of Widget.js is unchanged:

define(['dojo/_base/declare', 'jimu/BaseWidget'],
function(declare, BaseWidget) {

Any help with this is appreciated.

0 Kudos
1 Reply
MVP Esteemed Contributor


  When I put this in a widgets code it works fine for me:

      onOpen: function () {
        var visLyrs =;;

Can you share your whole Widget.js?

0 Kudos