Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:09:26+00:00 2026-06-04T06:09:26+00:00

I am working on an application and was doing something like this: dojo.ready( function(){

  • 0

I am working on an application and was doing something like this:

dojo.ready(
           function(){ require['dojo/parser','dijit/registry','dojo/on'],function(.....){
           //find a dijit and wrap it in event handling code.});

I was getting an error indicating that dojo was trying to register a widget with an id that was already in use. To solve the problem I entered this line of code:

           //before finding the dijit destroy the existing registry.

However, logically this prevents the next line from working because now no widget exists to which I can connect an event. How can I recover the dijit ids?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:09:27+00:00Added an answer on June 4, 2026 at 6:09 am

    The best solution is to find out why your code is trying to register a widget with an id that is already in use and change it to not to do so.

    The @mschr’s solution should work, but I would advise again using it, as it can break your code in many other places and you are likely to spend hours investigating strange behavior of your application.

    Anyway, if you are willing to do it that way and automatically destroy widgets with the same ID, do not override registry.add() method. You could do it, but it does not mean, you should do it (especially in programming). Employ dojo/aspect instead to call a function that will destroy the widget with the same ID before registry.add() is called:

    require([
        "dojo/aspect",
        "dijit/registry"
    ], function(
        aspect,
        registry
    ) {
    
        aspect.before(registry, "add", function(widget) {           
            if(registry.byId(widget.id)) {
                registry.byId(widget.id).destroy();
                // this warning can save you hours of debugging:
                console.warn("Widget with id==" + widget.id + " was destroyed to register a widget with the same id.");                    
            }
            return [widget];
        });
    
    });
    

    I was myself curious how to accomplish @mschr solution without that override, so I created an jsFiddle to experiment: http://jsfiddle.net/phusick/feXVT/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a graphical application which looks something like this: while (Simulator.simulating) {
I have a working application using python and zeromq and I would like to
I'm working on a blog like application, my user module has_many posts and the
I'm working on a small Rails application in which I'd like users to be
I'm working in an application that uses servlets and mysql. I'd like to create
I'm looking for something like this: {% trans There are %{flowers}n flowers in the
I've got (working) application done with ttk. It uses self-created module for showing a
I am working on splitting out an existing, working application that I currently have
I've try to implement integration tests for a working application (spring, hibernate, soap, cxf).
i am working in application of twitter in flex 3 and action script 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.