injecting or modifying DataTables responsive modal on open

injecting or modifying DataTables responsive modal on open

JLyon60JLyon60 Posts: 12Questions: 6Answers: 1

I am using the render function in the responsive extension to build a modal with data from a record in my table.

The modal includes a select dropdown with several options. If the field (from my db) tied to that select dropdown hasn't been populated, no problem. If it has, I want to add the "selected" value on the appropriate option line.

Also, the basic display of this select dropdown is driven by an onchange event attached to another dropdown (basically a cascading set of dropdowns).

The issue comes when the user selects a record that they have previously modified, so that dropdown #1 already has a value, so then when the modal launches, no onchange event is fired to show the 2nd dropdown with the appropriate selected value as the default/displayed value.

Is there a way to get to the modal in code after the render function has built the basic table and before the modal is actually displayed? Obviously, it's 1 line of code to add an ID to the modal. I tried building a simple function

$('div.modal.fade.dtr-bs-modal.in').on('show.bs.modal', function () {
  var statusReason = $('#rStat').val();
  console.log(statusReason);
// eventually more/other code will go here if I can get at the modal during load
})

but the event isn't being triggered (or at least the event handler isn't picking it up)

I'll try to put together a proper jsfiddle later today to better demonstrate what I'm asking

This discussion has been closed.