3

Context: component history screen, user clicks Rollback (Rollback command executes), a dialog appears with type of rollback (create new... vs delete all...), then user clicks Rollback button. At this moment, I want to do my stuff.

The problem is that if I plug into Rollback command, that happens BEFORE the dialog is displayed. I need to put my code AFTER the user clicks the Rollback button in the dialog.

7

To trigger your custom the event handler after the Rollback button is clicked, you'd have to get the controls of the Rollback button and register your custom function on an onclick event. In your event handler, check if the view is HistoryListDialog and get the controls of the Rollback button using its id RollbackBtn. Then you can register your onclick custom event on the Rollback button.

enter image description here

Configure your GUI extension as you'd normally do and in the constructor of the JS, register a display event handler $evt.addEventHandler($display, "start", this.getDelegate(this.onDisplay));. And the rest of your JS should be something like this:

function onDisplay()
{
       var view = $display.getView().getId();

       if (view == "HistoryListDialog")
       {
              $display.resize();

              // Get the controls of the "Rollback" button using its id.
              var BtnRollback = $controls.getControl($("#RollbackBtn"), "Tridion.Controls.Button");

              // Register an onclick event on the "rollback" button
              $evt.addEventHandler(BtnRollback, "click", this.getDelegate(this.onBtnRollbackCustomClick_));
        }
}

function onBtnRollbackCustomClick_()
{    
      console.log("Rollback button clicked");
}

This TREX post might help too.

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.