[Dojo-checkins] r1378 - trunk/src/widget

dojo-checkins at dojotoolkit.org dojo-checkins at dojotoolkit.org
Sat Sep 3 23:32:41 PDT 2005


Author: psowden
Date: Sat Sep  3 23:32:40 2005
New Revision: 1378

Modified:
   trunk/src/widget/Manager.js
Log:
generated widget IDs now increment based on the number of widgets of the specific type rather than the number of widgets in total


Modified: trunk/src/widget/Manager.js
==============================================================================
--- trunk/src/widget/Manager.js	(original)
+++ trunk/src/widget/Manager.js	Sat Sep  3 23:32:40 2005
@@ -6,16 +6,17 @@
 	this.widgetIds = [];
 	this.root = null; // the root widget
 
-	var widgetCtr = 0;
+	var widgetTypeCtr = {};
 
-	this.getUniqueId = function(){
-		return widgetCtr++;
+Ê Ê this.getUniqueId = function (widgetType) {
+		return widgetType + "_" + (widgetTypeCtr[widgetType] != undefined ?
+			widgetTypeCtr[widgetType]++ : widgetTypeCtr[widgetType] = 0);
 	}
 
 	this.add = function(widget){
 		this.widgets.push(widget);
 		if(widget.widgetId == ""){
-			widget.widgetId = widget.widgetType+"_"+this.getUniqueId();
+			widget.widgetId = this.getUniqueId(widget.widgetType);
 		}else if(this.widgetIds[widget.widgetId]){
 			dj_debug("widget ID collision on ID: "+widget.widgetId);
 		}


More information about the Dojo-checkins mailing list