I am implementing a Tridion 2011 (GA) GUI Extension on the Link Popup (the one that opens up when you click on the hyperlink button in a rich text area to enable to you select a component to link to, or url/mailto etc.).
I want to hook into the point where a component is selected or updated within this popup, so that I can load some data based on the selected component's schema. The problem is that the html input field that contains the component uri is disabled (as the value can only be changed by the selector), and I think this is preventing the change event from firing.
In my extension js I have the following, but the function is not called when I select/update a component, only when I change a http/mailto link
$evt.addEventHandler($("#FieldUrl"), "change", onFieldUrlChanged);
function onFieldUrlChanged()
{
alert("url changed to: " + $("#FieldUrl").value);
}
Is there some other event that would work? Otherwise, is there some way I can hook into the browse popup being closed?
UPDATE
Following Frank's suggestion I am trying to hook into events in the Select Item popup. I have now added an event handler for the browse button click
, which in turn adds event handlers for the popup. I was hoping to use insert
or even unload
, however rather annoyingly the only one which seems to fire is close
(which only happens when you do not select a linked component, so not much use to me). My JS code is below:
$evt.addEventHandler($("#BtnBrowse"), "click", onBtnBrowseClicked);
function onBtnBrowseClicked = function (event)
{
var popup = $display.getView().properties.ItemPopup;
$evt.addEventHandler(popup, "load", function () { alert('loaded'); });
$evt.addEventHandler(popup, "insert", function () { alert('insert'); });
$evt.addEventHandler(popup, "close", function () { alert('close'); });
$evt.addEventHandler(popup, "unload", function () { alert('unload'); });
}
Using the console I did manage to hook a click
event into the actual insert button in the popup, with something like this:
$evt.addEventHandler($display.getView().properties.ItemPopup.properties.view.properties.controls.insertButton, "click", function () { alert('stone the crows'); });
However if I add this in my browse click event handler it errors as $display.getView().properties.ItemPopup.properties.view
is null, perhaps as the popup has not fully loaded yet (and as just shown, the load event doesnt work, so I dont see how I can wait for it to load!).