Hey all! Has anyone come up with a bit of javascript to change the text on the confirmation prompt of a delete button? I would like to change the text from the standard, “Are you sure you want to delete this?”.

Hey all! Has anyone come up with a bit of javascript to change the text on the confirmation prompt of a delete button? I would like to change the text from the standard, “Are you sure you want to delete this?”.

Here is what I have tried below
Custom JavaScript to Override Confirmation Text:
$(document).on('knack-view-render.view_285', function(event, view) {
$(view.el).on('click', 'a.kn-delete', function(e) {
e.preventDefault(); // Prevent the default action
// Custom delete confirmation message
var confirmDelete = confirm("Are you sure you want to delete this record? This action cannot be undone.");
if (confirmDelete) {
var recordId = $(this).data('record-id'); // Get the record ID from data attribute
Knack.showSpinner();
Knack.views[view.key].model.deleteModel(recordId, {
success: function(model, response) {
Knack.hideSpinner();
location.reload(); // Reload after deletion
},
error: function(model, response) {
Knack.hideSpinner();
alert('There was an error deleting the record.");
}
});
}
});
});
Custom JavaScript to Create a Custom Delete Button:
$(document).on('knack-view-render.view_285', function(event, view) {
// Add a custom delete button
var buttonHTML = '<button id="custom-delete" class="kn-button is-danger">Delete Record</button>';
$(view.el).append(buttonHTML);
// Handle click on the custom delete button
$('#custom-delete').on('click', function(e) {
e.preventDefault();
var recordId = Knack.models[view.key].get('id'); // Get the record ID
Knack.showSpinner();
$.ajax({
url: 'https://api.knack.com/v1/objects/' + view.source.object + '/records/' + recordId,
type: 'DELETE',
headers: {
'Authorization': Knack.getUserToken(),
'X-Knack-Application-Id': Knack.application_id,
'X-Knack-REST-API-Key': 'knack',
},
success: function(response) {
Knack.hideSpinner();
location.reload(); // Reload after deletion
},
error: function(xhr, status, error) {
Knack.hideSpinner();
alert('There was an error deleting the record.');
}
});
});
});
Custom JavaScript to Remove the Confirmation Prompt Entirely:
$(document).on('knack-view-render.view_285', function(event, view) {
// Unbind the default click event and directly delete the record without confirmation
$(view.el).find('a.kn-delete').off('click').on('click', function(e) {
e.preventDefault(); // Prevent the default action
var recordId = Knack.models[view.key].get('id'); // Get the record ID
// Perform the deletion using Knack's built-in model method
Knack.showSpinner();
Knack.views[view.key].model.deleteModel(recordId, {
success: function(model, response) {
Knack.hideSpinner();
location.reload(); // Optionally reload the page or redirect the user
},
error: function(model, response) {
Knack.hideSpinner();
alert('There was an error deleting the record.');
}
});
});
});
None of the above work. I have managed to get a second prompt but cannot remove the first or change the text.
I’m looking to either:
Any assistance with this would be so greatly appreciated!!!