Hi,
Does anyone know how to change the delete message window with your own message, using JS.?
Thank you
As far as I know …
In Knack, the confirmation popup you’re seeing when clicking a delete action button is a native browser alert triggered by Knack’s internal JavaScript. Unfortunately, because it uses the window.confirm()
method, you cannot directly change the text or styling of that popup — it’s controlled by the browser, not Knack or custom scripts.
This is one of the many reasons that a lot of Knack developers tend to use “soft deletes”. By this I mean to add a “Marked for Deletion” flag to records, and on user views filter out records that have been marked for deletion, so they are effectively “gone” from the user’s world.
Now a “delete” is a simply an action button to change the flag from its default NO to YES.
You can then manually delete these marked records on a regular basis from the Builder - and in the meantime if someone deleted something accidentally it is trivial to restore it.
Thank you.
Yes, you can customize the “delete message” confirmation in JavaScript by replacing the default browser confirm()
dialog with your modal or message.
However, if you’re referring to the built-in confirm()
function (e.g., if (confirm("Are you sure you want to delete this message?"))
), you cannot change its appearance or customize it beyond the message text—it’s controlled by the browser.
Im not sure which dialogue you’re referring to, can you take a screenshot?
One alternative is on your grid, instead of adding a Delete action, add a “Details Page” instead. Tell the field to show with the trash can icon, and you can style it exactly the same as the real one. Set the details page as a modal pop up, and you can type any warnings you want, and even show any connections that record has to remind the user. (in our case, we use Knack as a CMS for our touch screen displays, and in this pop up we remind the user that this record is connected to X displays at X locations)
Then, add your Delete action on the details pop up and call it “Confirm Delete” and I often restyle it so it’s larger. OR, instead of delete, you could also use this with the soft delete that Carl mention above, and use a “trigger an action” to update a soft delete field to YES so that the record is filtered out instead of deleted.
Cool.Thank you.