Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2609)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2610)
@@ -97,5 +97,5 @@
 			contents : {},
 			buttons : {}
-		}, true);
+		}, true );
 
 	// Initialize the parts map.
@@ -1329,9 +1329,10 @@
 				attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
 				innerHTML = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition ) : contentsArg ) || '',
-				id = this.id = attributes.id || elementDefinition.id || CKEDITOR.tools.getNextNumber() + '_uiElement',
+				domId = this.domId = attributes.id || CKEDITOR.tools.getNextNumber() + '_uiElement',
+				id = this.id = elementDefinition.id,
 				i;
 
 			// Set the id, a unique id is required for getElement() to work.
-			attributes.id = id;
+			attributes.id = domId;
 
 			// Set the type and definition CSS class names.
@@ -1490,7 +1491,18 @@
 	 * uiElement.getElement().hide();
 	 */
-	getElement: function()
-	{
-		return CKEDITOR.document.getById( this.id );
+	getElement : function()
+	{
+		return CKEDITOR.document.getById( this.domId );
+	},
+
+	/**
+	 * Gets the parent dialog object containing this UI element.
+	 * @returns {CKEDITOR.dialog} Parent dialog object.
+	 * @example
+	 * var dialog = uiElement.getDialog();
+	 */
+	getDialog : function()
+	{
+		return this._.dialog;
 	},
 
Index: /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2609)
+++ /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2610)
@@ -109,5 +109,5 @@
 				initPrivateObject.call( this, elementDefinition );
 				var attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {},
-					id = this._.inputId = attributes.id || elementDefinition.id, 
+					domId = this._.inputId = attributes.id || CKEDITOR.tools.getNextNumber() + '_textInput',
 					styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {},
 					inputContents = ( contentsArg && contentsArg.call ? contentsArg( dialog, elementDefinition) : contentsArg ) || '',
@@ -118,10 +118,8 @@
 					this._['default'] = '';
 
-				// Set the id for the inner input element.
-				if ( id )
-				{
-					id = this._.inputId = id + '_textInput';
-					attributes.id = attributes.name = id;
-				}
+				// Set the id and name for the inner input element.
+				attributes.id = domId;
+				if ( elementDefinition.id )
+					attributes.name = elementDefinition.id;
 
 				// Set the type.
@@ -317,17 +315,18 @@
 								CKEDITOR.document.on( 'mouseup', function( evt )
 									{
-										var target = evt.data.getTarget();
+										var target = evt.data.getTarget(),
+											activeButton = CKEDITOR.ui.dialog.button._.activeButton;
 
 										// If there's no active button, bail out.
-										if ( !CKEDITOR.ui.dialog.button._.activeButton )
+										if ( !activeButton )
 											return;
 
 										// Change styles to remove active status.
-										CKEDITOR.ui.dialog.button._.activeButton[1].removeClass( 'active' );
+										activeButton[1].removeClass( 'active' );
 
 										// Fire the click event - but only if the
 										// active button is the same as target.
-										if ( CKEDITOR.ui.dialog.button._.activeButton[1].equals( target.getAscendant( 'table' ) ) )
-											CKEDITOR.ui.dialog.button._.activeButton[0].fire( 'click', { dialog : dialog } );
+										if ( activeButton[1].equals( target.getAscendant( 'table' ) ) )
+											activeButton[0].fire( 'click', { dialog : activeButton[0].getDialog() } );
 
 										// Clear active button flag.
