AnsweredAssumed Answered

What is the right way to extend/modify a popup in WebAppBuilder 2.0?

Question asked by thultgren on May 18, 2016
Latest reply on May 31, 2016 by rscheitlin

In version 1.x of WebAppBuilder popups seemed to be handled by the AttributeTable\Widget.js code, and by adding a little bit of code to the jimu/InfoWindowAction section of that Widget.js file we were able to execute a little bit of JavaScript code after a popup had been rendered to enhance and improve aspects of the popup. It was a bit of a hack, but it worked - happy to share more details if anyone's interested.

In version 2.0 of WebAppBuilder, though, it appears as if all of the popup rendering is performed using code from the JavaScript API -, specifically esri/dijit/PopupRenderer - so our hack won't work unless we were to pull that code locally, and we'd really prefer not to do that. Instead we're trying to do things the right way - by using Dojo Inheritance to extend the PopupRenderer class. 

dojo/_base/declare — The Dojo Toolkit - Reference Guide

We know that any extension has to occur after the API has been loaded, so we're working within the dynamic-modules/postload.js file, which does seem to be executed at the right time.  Our very simple code block is here:

    return popupRenderer.extend({
        _handleComponentsSuccess: function(){

According to our understanding, this inherits the existing PopupRenderer class, it then returns an extended version of that class with an altered _handleComponentsSuccess function, and this.inherited(arguments); is the technique to use to call the superclass method (so we don't overwrite it). In practice, everything about this code works except for that calling of the superclass method - a "success" is logged to the console every time a popup is supposed to be rendered, but the internal content of the popup is never populated - the original _handleComponentsSuccess code is never executed (We've tried extending the .startup function as well).  So what are we missing?  Is there a different way to extent esri dijits? Or are we misunderstanding the concept of Dojo inheritance? Or is WebAppBuilder just a different ballgame? If we can get this right, it seems like it should be a really elegant way to perform small enhancements.  Thanks in advance.