Use a method to generate confirm() links

This allows for overriding the the default behavior of showing a
confirm()-dialog.
Use json_encode to escape confirm() messages