The confirm-box message appears like it should when the link is clicked.
<%= link_to 'Close Account',
@profile,
:confirm => "Are you sure?",
:method => :delete
%>
When the confirm-box appears, the “OK” button is selected by default; I want the “Cancel” button selected by default, so that if the user accidentally presses enter then the profile record will be safe and will not be deleted.
Is it possible to have the “Cancel” button selected?
The confirm box is generated by Javascript, using an attribute selector in Rails (note
data-confirm) on the element. Unfortunately, this box is generated by the browser, so there’s no real direct control over it. If you’re using the latest version of Rails, I suggest looking into jQuery UI, and using the dialog library. Here, you can make custom confirmations, and maybe even an attribute binding such asdata-uiconfirm. Which would look like this:And the attribute binding like so: