How do I use Bootstrap theme’s modal.jquery.ui.bridge’s mapped events?

I am using a Bootstrap subtheme, and would like to trigger an event when a modal is closed.

Reviewing the main theme’s modal.jquery.ui.bridge.js file, I see that the bridge is intending to map jQuery UI events (beforeClose, close) to framework events (,

I’m struggling with figuring out how to properly declare the data-dialog-options attribute of the triggering link to pass this event through the bridge.

In the JS file, this.options.jQueryUiBridge is true when typeof options === 'object'. My guess is that my options are not typeof object.

My attributes array on the Url object is

  $  attributes = [     'class' => ['use-ajax'],     'data-dialog-type' => 'modal',     'data-dialog-options' => Json::encode([       'dialogClass' => 'modal-content--special-class',       'beforeClose' => 'function() {console.log("closed");}',     ]),   ]; 

which results in the rendered link

<a href="/my-content-route" class="use-ajax" data-dialog-type="modal" data-dialog-options="{&quot;dialogClass&quot;:&quot;modal-content--space-wizard&quot;,&quot;beforeClose&quot;:&quot;function() {console.log(\u0022closed\u0022);}&quot;}">My Link Text</a> 

What am I missing?