I am creating a GUI extension that includes a popup that opens by clicking a new button in the ribbon bar. The pop-up window includes a drop-down list that is dynamically populated with some information collected from the system using Core Service. At least this idea. I can make the button appear and it opens a popup, but as soon as I start with javascript for the popup, I get a Unable to get unique id for element error message, and the CME does not finish loading. Here is what I still have:
Popup aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SwitchUserPopup.aspx.cs" Inherits="SwitchUser.Popups.SwitchUserPopup" %> <%@ Import Namespace="Tridion.Web.UI.Core" %> <%@ Import Namespace="Tridion.Web.UI" %> <%@ Import Namespace="System.Web" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://www.sdltridion.com/web/ui/controls"> <head runat="server"> <title>Select User</title> </head> <body> <form id="form1" runat="server"> <div> <h1>Select User</h1> <c:dropdown id="SwitchUserDropdown" runat="server" nullable="false"/> </div> </form> </body> </html>
ASPX pop-up code
namespace SwitchUser.Popups { [ControlResourcesDependency(new [] { typeof(Popup), typeof(Tridion.Web.UI.Controls.Button), typeof(Stack), typeof(Dropdown), typeof(List) })] [ControlResources("SwitchUser.Resources")] public partial class SwitchUserPopup : TridionPage { protected override void OnInit(EventArgs e) { base.OnInit(e); TridionManager tm = new TridionManager(); tm.Editor = "SwitchUser"; System.Web.UI.HtmlControls.HtmlGenericControl dep = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency"); dep.InnerText = "Tridion.Web.UI.Editors.CME"; tm.dependencies.Add(dep); System.Web.UI.HtmlControls.HtmlGenericControl dep2 = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency"); dep2.InnerText = "Tridion.Web.UI.Editors.CME.commands"; tm.dependencies.Add(dep2);
Popup js
Type.registerNamespace("SwitchUser.Popups"); SwitchUser.Popups.SwitchUser = function (element) { Type.enableInterface(this, "SwitchUser.Popups.SwitchUser"); this.addInterface("Tridion.Cme.View"); }; SwitchUser.Popups.SwitchUser.prototype.initialize = function () { $log.message("Initializing Switch User popup..."); this.callBase("Tridion.Cme.View", "initialize"); var p = this.properties; var c = p.controls; c.UserDropdown = $controls.getControl($("#SwitchUserDropdown"), "Tridion.Controls.Dropdown"); }; $display.registerView(SwitchUser.Popups.SwitchUser);
The extension is correctly configured in System.config - I see a log message in the javascript console. However, I also see this Unable to get unique id for element error with the following additional information:
anonymous (object {..})
WebRequest.completed (object {..})
Net.loadFile $ OnComplete (object {..})
Net.loadFile $ onOperationCompleted ()
Xml.loadXmlDocuments $ onSuccess (array 1 )
Xml.loadXmlDocument $ onSuccess (array 1 )
Dropdown.setup $ filesLoaded (object {..})
setupDone ()
anonymous (function: DisplayController $ start ())
DisplayController.start ()
anonymously()
anonymous (undefined, "Tridion.Controls.Dropdown")
Tridion.Assert $ raiseError ("Unable to get unique identifier for item.")
From this logged information, the problem seems to be a drop down list. If I comment out the line in my JS that registers the view, I don't get the error, but I also don't get the log message, so I suspect this is a must call. Can anyone shed some light on why this might happen? I am using PowerTool Sample Code as a reference, and I believe that I reproduced what is there ..
Update
I tried to execute the code - I found a suitable line and placed a breakpoint there. Then I rebooted CME, and suddenly my breakpoint was on a line that had nothing to do with my code, and I could not find anything related to my code. However, according to the console, it is still running.
So, instead, I put the log messages in my initialization method as follows:
SwitchUser.Popups.SwitchUser.prototype.initialize = function () { $log.message("Initializing Switch User popup..."); this.callBase("Tridion.Cme.View", "initialize"); $log.message("Tridion.Cme.View callBase done"); var p = this.properties; var c = p.controls; $log.message("Set properties and controls"); c.UserDropdown = $controls.getControl($("#SwitchUserDropdown"), "Tridion.Controls.Dropdown"); $log.message("Got UserDropdown control"); };
I see in the console that it registers before Set properties and controls , and then I get an error.