Reputation: 1090
I have a function where a user can reset their own password by entering their registered email and clicking a button. An email then gets sent to that address.
<div class ="title">Reset your password</div>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div class="signup">
<div class = "field">Email:
<%= f.email_field :email, :class => "email" %></div>
</br>
<div><%= f.submit "Send me reset password instructions", :class => "button", :confirm => "An email to reset your password has been sent" %></div>
</div>
<% end %>
I am wanting a pop up box to show up after they hit the submit button. I have a confirm pop up at the moment, but I am just wanting an alert popup, where the user only has the option to click "OK". Can this be done?
I am new to rails, so please remember this when trying to help. Thanks in advance.
Upvotes: 2
Views: 9503
Reputation: 6781
You could use:
<%= f.submit "Send me reset password instructions", data: { confirm: 'Are you sure?' } %>
Upvotes: 13
Reputation: 8258
This kind of functionality is not built into Rails but you can always use JavaScript:
f.submit "Send me reset password instructions", :class => "button", :onclick => "alert('Input collected!')"
My preferred solution would be to add a data-alert-message attribute to the button and attach the onclick event through javascript on DOM load unobtrusively, but I'm not going to explain that since it has nothing to do with Rails.
Upvotes: 4