6

We are trying to write a GUI extension to showcase some information to the Editor. For this we show a popup with the required information to the editor, unfortanetly we are unable to add some buttons, our code looks like as followed;

var options = {};
options.className = "question";
options.popupType = $popupManager.Type.MESSAGE_BOX;
options.title = "This is a popup!";

var btnConfirm = {action: "confirm", label: "Yes", showInPanel: false, showInPopup: true};
var btnCancel = {action: "cancel", label: "No", showInPanel: false, showInPopup: true};

options.buttons = [btnConfirm, btnCancel];

var popup = $popupManager.createExternalContentPopup(null, $cme.Popups.MESSAGE_DETAILS.FEATURES, options);
$evt.addEventHandler(popup, "confirm", onCopyConflictPopupSubmit);
$evt.addEventHandler(popup, "cancel", onCopyConflictPopupClosed);
popup.open();

Without adding the options.buttons we get the popup with a close button. Looking in MessageBoxPopup.js we see that we can add buttons like above. But when we do that we get below error; Any suggestions on how to resolve this?

Uncaught TypeError: Cannot read property 'focus' of undefined at Tridion.Controls.MessageBoxPopup.focus (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:59) at a (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:55)

Uncaught TypeError: Cannot read property 'focus' of undefined at Tridion.Controls.MessageBoxPopup.focus (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:59) at Tridion.Controls.MessageBoxPopup.Tridion.Controls.BaseModalPopup._handleFocusOutside (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:56) at Tridion.Controls.FocusOutsideMonitor. (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:1) at Tridion.EventRegisterClass.f.executeListener (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:14) at Tridion.Controls.FocusOutsideMonitor.a (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:14) at Tridion.Controls.FocusOutsideMonitor.Tridion.ObjectWithEvents.processHandlers (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:12) at Tridion.Controls.FocusOutsideMonitor.Tridion.ObjectWithEvents.fireEvent (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:12) at Tridion.Controls.FocusOutsideMonitor._doFocusOut (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:50) at Tridion.Controls.FocusOutsideMonitor.a (coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:50) at coreresource_v7.1.0.66.43_.js?sav=1&cnt=core:1

2

With this way of creating popups the only event that seems to emit on clicking the buttons is a dialog_closed event. In that event you recieve an Tridion.Core.Event object with the clicked button information such as the action property.

So you could do something like:

$evt.addEventHandler(popup, "dialog_closed", handleButtonActions);

And handle the actions you want inside handleButtonActions function.

The only reason I see to create a popup like this it's because you want a simple popup to get some sort of explicit confirmation before an action. If you want to give it more functionality and/or be able to handle events like you are trying to, you should create your own popup view.

  • but (assuming) it goes through MessageBoxPopup.js ,,, in the _buildMessageBox function is does a check for buttons. If there is no buttons it adds a close button. But i assume it goes through the loop and creates the custom buttons? – jarnohenneman Aug 18 '17 at 7:52
  • That's true. It creates the buttons you tell it to create. But the only event they will fire will be dialog_closed. You can check that through _addEventHandlers it adds _handleButtonClick as the only click listener for all buttons, and that function only emits dialog_closed events. I only found references to this popup on the MessageCenter and UserInfoBar so it looks like MessageBoxPopup it's intended to be used only with simple confirmations for messages because at some point actions will be used to fire events with $messages.executeAction. – Diego Rodríguez Aug 18 '17 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.