Standalone editor won't call ssp
Standalone editor won't call ssp

I have a need to edit the data on a table not shown, and for some reason, I cannot get editor to call the ssp script.
let selectedFacilityID = null;
const facilityEditor = new $.fn.dataTable.Editor( {
ajax: {
url: baseUrl + "modules/database/ssp_facilities.php",
type: "POST",
error: function (xhr, error, thrown) {
console.error('AJAX Error:', error, thrown);
console.error('XHR:', xhr);
}
},
idSrc: "Facility_ID",
template: '#facForm',
fields: [ {
name: "Facility_Type",
type: "select",
className: 'full block'
}, {
...
}
]
} );
$('#printerTable tbody').on('click', 'tr', function () {
var data = ( table.row( this ).data() );
// The facility ID should come from PrisonFacilityListing, not form.FAC_ID
selectedFacilityID = data.PrisonFacilityListing.Facility_ID;
...
})
}
$('#editFacilityBtn').on('click', function () {
if (!selectedFacilityID) {
alert('No facility selected. Please select a row in the table first.');
return;
}
console.log('Selected Facility ID:', selectedFacilityID);
facilityEditor
.edit(selectedFacilityID)
.title('Quick Edit Facility')
.buttons([
{
label: 'Save',
className: 'btn-sm lnk-modal-button',
fn: function () {
this.submit();
}
}, {
label: 'Cancel',
className: 'btn-sm lnk-modal-button',
fn: function () {
this.close();
}
}
])
.open();
});
Standalone editor opens fine, template is fine, but no data, when watching the network calls, it never calls ssp_facilities.php
I can do this by hand, but standalone should be able to do this. What do I need to do to initiate the ajax call?
To be clear, selectFacilityID does contain the id, and it is a correct ID as it is visibly showing a proper left join in a different table, the one selected above.
Answers
Are you able to give me a link to the page showing the issue please? I'm not immediately seeing what would cause it Ajax URL not to be called there.
Thanks,
Allan
Yup, I'll send it to you
Thanks to Allan for the nudge—his comment about needing to use the API manually got me thinking differently about how to handle the facility editor.
What I had before wasn’t working: the standalone Editor wasn’t triggering an AJAX call to ssp_facilities.php, even though the config followed the docs. No errors, just silence. Turns out, standalone editors don’t automatically load data when calling .edit(id).open(), even though the documentation implies they should.
Here’s what works now:
This fixed the issue and gave me a much faster, more reliable setup. So if you’re using a standalone Editor and it’s not loading data like you expect, this approach might save you some serious time.