A button controls visibility of a modal dialog. This occurs in the context of a forms engine, so the controlled modal dialog is determined by knockout binding.
<button type="button" class="btn btn-primary" data-toggle="modal"
data-bind="attr: {
id: 'attachment' + Metadata.FormFieldID,
'data-target': '#attachment-dialog' + Metadata.FormFieldID
}">
The dialog is itself bound to a viewmodel of a file system. If a value has already been supplied it is supposed to show the containing category and preselect the specified document.
This works fine but the viewmodel is prepped before the view is rendered, so scrolling the selection into view silently fails.
I could stop using data-toggle and explicitly control dialog visibility, but I would like to know whether there is any way to detect that the dialog has been toggled to visible so that I can trigger code to scroll the selection into view.
So there's the question: How can I detect that data-toggle has made a dialog visible using data-* attributes?
I am aware of
$('#myModal').on('shown.bs.modal', function (e) {
// do something...
})
but this is a forms engine and the UI is rather dynamic so managing the event subscription would be mucky.