ERROR

Tried to register widget with id==<widget name> but that id is already registered

Last Published: April 25, 2020

Error Message

When loading a web map containing widgets, the following error message is returned:

Error:   
Error: Tried to register widget with id== but that id is already registered
Image of the error message in Javascript API

Cause

This error occurs if the ID used to register a widget already exists in the system, or when attempting to create multiple widgets with the same HTML element ID. 

Functions or objects may attempt to call a different widget that contains a similar ID, which has been registered, when executed. Despite performing different tasks, the system detects the conflicts in the ID and returns the error message, preventing users from overwriting the registered widget.

For example, the Legend widget and LayerList widget is defined with the same HTML element ID, legendDiv.

Image of the HTML element ID

Solution or Workaround

The are two possible solutions for this issue: 
  • Provide a unique HTML element ID
When instantiating a widget, ensure the widget is defined with a unique HTML element ID. For more information, refer to ArcGIS Help: Widget
  • Destroy and re-create the widget
Remove the widget completely by using the destroy method in the widget's class as shown in the following code snippet. The destroy method removes the widget from the HTML element, allowing the application to re-create a new widget in the same HTML element ID. The following is a sample code snippet for destroying a widget:
function destroyEditor() {  
       if (editorWidget) {  
         editorWidget.destroy();  
         editorWidget = null;  
       }  
}

Article ID:000014655

Software:
  • ArcGIS Online
  • ArcGIS API for JavaScript 3 x
  • ArcGIS API for JavaScript 4 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options