Login Register

Already registered widget (error message on 1.0)

I'm currently testing dojo 1.0.0 version.

on a perfectly working page with the 0.9, i've got an error message:

"Tried to register widget with id==layout but that is is already registered"

(this Id is used for a dijit.layout.LayoutContainer object.)

I'm looking in the porting guide but there's nothing about changes on these objects.....

Someone?

thanks

Me too

I also get this error after upgrading to 1.0 from 0.9.
None of my code has changed during the upgrade.
I too get this error for a LayoutContainer, in particular, the subContainerWidget node of a custom widget.
Wierdly, if I remove the id html attribute from the layoutContainer in question and fall back to dojo's autonaming (LayoutContainer_x) then I still get the same error.
I think that this probably has to do with the changes in programatic widget construction.
Currently, I have a method to add a tab to a tab container:

myNamespace.addTab = function( tab, widget ) {
    console.debug( " : addTab" );

    var tmp = document.createElement('div');
    var cp = new dijit.layout.ContentPane( tab, tmp );
    myTabStrip.addChild( cp );
    cp.setContent( widget.domNode );    
    dojo.addClass( cp.domNode, "noOverflow" );
}

I get the error mentioned about ID clashes on the construction of the ContentPane.
In 0.9 this was the only way to programatically add a tab. Should this be performed differntly in 1.0, e.g:

myNamespace.addTab = function( tab, widget ) {
    console.debug( " : addTab" );

    var cp = new dijit.layout.ContentPane( {"id": "tempID" }, tmp );
    myTabStrip.addChild( cp );
    cp.setContent( widget.domNode );    
    dojo.addClass( cp.domNode, "noOverflow" );
}

[solved]

The duplicate widget declaration happens when you try and create the same widget twice and therefore get an ID clash.
In some cases this would be due to having the page level parser enabled and creating the widget programatically, e.g.

djConfig.parseOnLoad = true OR calling dojo.parser.parse
and then creating a widget that has already been parsed.

In my case it was due to the parseOnLoad becoming enabled (bug fixed ?) from 0.9 to 1.0 with the contentPane.
***NOTE*** contentPane.parseOnLoad defaults to TRUE in 1.0 (and works) so I had to turn this off when adding custom widget domNodes using setContent.

In case anyone is following this, my ammended addTab:

myNamespace.addTab = function( tabCtor, widget ) {
    console.debug( " : addTab" );

    var cp = new dijit.layout.ContentPane( tabCtor );
    cp.setContent( widget.domNode );
    myTabStrip.addChild( cp );
    dojo.addClass( cp.domNode, "noOverflow" );
}

where tabCtor is: { id: "tab1", title: "Tab One", parseOnLoad: false } ;

ok. I find the problem.....

the origin of my problem was in my ...

I've got a loader on my page:

function hideLoader(){
var loader = dojo.byId('loader');
dojo.fadeOut({ node: loader, duration:500, onEnd: function(){
loader.style.display = "none";
}}).play();
}

dojo.addOnLoad(function() {
var start = new Date().getTime();
dojo.parser.parse(dojo.byId('layout'));
dojo.byId('loaderInner').innerHTML += " OK !";
setTimeout("hideLoader()",250);
});

I got the error......
and if I comment the line: dojo.parser.parse(dojo.byId('layout')); It works :s
Maybe we've have to look around the dojo parser !!!

could be caused by...

It could be caused by you doing setContent(widget.domNode) this clones the widget.domNode node which *may* contain the widgetId attribute and then attempts to parse it...if you are creating a TabContainer and inserting a widget into it... depending on what it is, you can usually use that widget as a direct child of the TabContainer (just asign it a title attribute so it gets a tab name) instead of wrapping it in a ContentPane (Adding extra overhead and complexity)

-Karl

can't fix that problem

hi,
using dojo 1.0 i'm trying to build a standard application layout :


top
main content

In two words : a header, a left menu and a main content. The goal is to call external php files and includes them in the main content pane.

I've searched many hours and i stay troubled...

1) Why the "setUrl" function return always "dojo.byId("centre").setUrl is not a function" for example by using this piece of code (which is in the head section of my page):

function open_link(){

	dojo.byId("centre").setUrl('admin/user.php');
}

?
Do I have missed importing something ?

dojo.require("dijit.layout.ContentPane");
		dojo.require("dijit.layout.LayoutContainer");
		dojo.require("dijit.form.Button");
		dojo.require("dijit.Dialog");
		dojo.require("dijit.form.TextBox");
		dojo.require("dijit.form.FilteringSelect");
		dojo.require("dojo.parser");

2) The only way i've found making it working is:

function open_link(){
          
             dijit.byId("centre").setHref('admin/user.php')

}

but when clicking for the second time the link that fire this function, the console gives me "Couldn't create widgets in centre from admin/user.php Error: Tried to register widget with id==my_widget but that id is already registered"

I've noticed that deleting the id of the concerned widget fixes the error, but what if i want to target it later ?

Thanks a lot (and sorry for my bad english...)

dave

Another reason for this issue

Just find out another reason for this error:
If your element is defined with "dojotype" not "dojoType", and this happened even in dojo examples such as in comboxo and checkbox. you got such errors.

It could be solved by replacing "dojotype" with "dojoType".

This is a major error ...Is any fix coming

It has broken all my pages which were working perfectly in Dojo 0.9
Is any fix for it coming asap ?

Parse twice

Hi,
I have the same problem, and I believe that it comes from parsing the same page twice.
I need to do this since I modify the page code dynamically.
I hope to get around this problem by parsing only selected Elements or by creating widgets programatically,
but of course this error is not nice.

Well I had it all throughout

Well I had it all throughout my application, as all things are created on fly,
and then I need to ir again and again
Unless this error is fixed, am not sure I can go ahead and redesing everything.

There should atleats be a

There should atleats be a way of unregistering that id if it is the cause of problem

dojo.xhrGet replacing a div needs parsing

When I click on a node in a tree, I am using dojo.xhrGet to replace a div with more code that needs parsing.
When I click on another, I need to parse it again.
I am getting the same error:
Error: Tried to register widget with id==userForm but that id is already registered

In my use case, I need to parse it again, because I replaced the content.
How do I unregister previous content, or make it so I don't care if I get a duplicate? (exception handler?) or have a flag to ignore duplicates?

// load the template
        dojo.xhrGet( 
        {    
            url: "user.html",
            handleAs: "text",
            timeout: 5000, // Time in milliseconds
            load: function(response, ioArgs) 
            { // successful response.
                var detailsPane = dojo.byId("detailsPane");
                detailsPane.innerHTML = response; 
                
                dojo.parser.parse(detailsPane); // to make dijits real
                
                // fill in the data
                dijit.byId('userForm').setValues(person);
                       
                return response;
            },
            error: function(response, ioArgs) 
            {
                console.error("HTTP status code: ", ioArgs.xhr.status);
                return response;
            }
          }
       );

destroy widget first...

hi,
before parse new content you must destroy old widget.

see destroyRecursive function of widget.

Or using destroy function (something like this):

dojo.query('[widgetId]', dojo.byId('divId')).forEach(function(w){w.destroy();});

"w.destroy is not a function"

This is the error i get when i try your solution FraFa.

So then, the problem stay the same.
Any solutions?

Need to use dijit.byId(...) first

I was struggling with this for a while too.... try the following:

dojo.forEach(
  dojo.query('[widgetId]', document.getElementById(elementId)),
    function(widget) {
      // For some reason I can't access widget.widgetid; trim the "widget_" prefix off of the id
      var widgetId=widget.id.substring(7);
      if (dijit.byId(widgetId)) {
        dijit.byId(widgetId).destroy();
      }
    }
);

(elementId is the ID for the DOM node which contains the widgets I want to delete)

Martin

my error is...

Martin you also resolve my error in code posting before, i use dojo.byId to get the DOM node and i use destroy on it, but destroy is a function of widget retrieve by dijit.byId...

sorry for mistake.

additional fix for dialog control

I ran into the same issue and fixed it by explicitly destroying everything before setContent. But then the hide function in Dialog.js was giving me problems on subsequent refreshes. For some reason this.domNode and this.bgIframe were undefined. I added checks in and now everything is working. Will the main problem with setContent and dialogs be fixed in 1.1 and anyone have any idea when 1.1 will be out?

hide: function(){
   if (this.domNode){
      this.domNode.style.display = "none";
   }
   if(this.bgIframe && this.bgIframe.iframe){
      this.bgIframe.iframe.style.display = "none";
   }
   this.disconnect(this._resizeHandler);
}

1.1 release plan

Hi!

I'm having the xhr problem where there can be very many different element id:s that I may want to destroy. Can I dojo.query() for all dijit.form.DateTextBox and have them destroyed?

DateTextBox datePattern ad selector attributes

Hi all,

With Dojo 1.0.1 I've tried to use attribute datePattern for widget DateTextBox to format date as "dd/MM/yyyy" but it doesn't work. However, if I use constraints attribute as:
constraints="{datePattern: 'dd/MM/yyyy'}"
Works perfectly.

Is this a known bug ?

Another info: is possible to use attribute selector to choose time from the popup calendar of the DateTextBox ?

Thanks !

Sorry, post error !

Sorry, It would be a new thread

with dijit.dialog

I have the same problem with dijit.Dialog

I am creating an innerHTML in the dialog and when I open that dialog a second time it gives me this error of "tried to register widget with id==xxxx".

I am using Dojo 1.1.0

This is my javascript

var editCompany = function () {
        var node = document.createElement("div");
        node.innerHTML = dojo.byId("editCompanyDiv").innerHTML;
        dojo.body().appendChild(node);
        dojo.addClass(node, "testFixedSize");
        var tmp = new dijit.Dialog({
                                id: "editPOCDialog",
                                title: "Edit Company Details",
                                parseOnLoad: false,
                                refreshOnShow: true
                                }, node);
                                tmp.show();               
};

any help would be great.

thanks.

You probably have a couple

You probably have a couple of options:

  1. dijit.byId('editPOCDialog').destroy() before creating the dialog again.
  2. Create the dialog once and just replace its contents as needed.

grid destroy

I am using dojox Grid which is created programmatically. Now I need to refresh the grid on an action in another grid. somehow once I destroy the grid and then try to render the grid again I dont see the grid data (somehow the div grid container is removed from generated html) Here is my relevant code. Would appreciate any suggestions.

if(grid){
        			console.info('Grid will be destroyed and recreated !');
	        		grid.destroy();
	        		
            		grid=null;
	     		 }	 
	     		     
				//dojo.byId("existingGrid") = "";	     	
				//var gridDiv=document.createElement("div");
				//dojo.byId("existingGrid").appendChild(gridDiv);	            

	            grid = new dojox.Grid({ 
	                    model: usersModel, 
	                    structure: layout,
	                    onRowClick: areaLinkClicked
	            }, dojo.byId("existingGrid"));
	           
                                //grid.startup();
				//grid.render();
				//grid.update();

modify

Can i modify it like this?

add:function(_1){
if(this._hash[_1.id]){
throw new Error("Tried to register widget with id=="+_1.id+" but that id is already registered");
}
this._hash[_1.id]=_1;
}
------〉
add:function(_1){
if(!this._hash[_1.id]){
//throw new Error("Tried to register widget with id=="+_1.id+" but that id is already registered");
this._hash[_1.id]=_1;
}
}

same Problem in IE 6+ & Opera while work fine in firefox 3

i am trying to add child in tab programetically but the problem is that when i run the page in mozilla firefox 3.0.5 its work fine without any error msg while in all other browser its print "tried to register with id ==child_tab_show_project_list_child but that id is already registered" i also use destroy() function but no help, below is the function which is trigged on "onclick" function of image. pls look and pls point out my silly error
----------------------------
function open_tab(master_tab, id, title, href)
{
var tabid = "child_tab_" + id;
var tabs = dijit.byId(master_tab);
var pane = new dijit.layout.ContentPane({
id: tabid,
title: title,
href: href,
closable: true,
refresOnShow: true,
parseOnLoad: false
});
tabs.addChild(pane);
tabs.selectChild(pane);
}
--------------------------------
Dojo version : 1.2.3
pls help me thx in advance.

fixed

sorry my mistake, i was using width:100% in style of tabcontainer, thats y problem was occuring

-----------------------

is their any way to use width:100%, to use 100% space of screen in tabcontainer

Thx again