Reputation: 35
I am creating a popup box for reset password and below is the button where I click to open popup box:
<table align="center" width="80%">
<tr>
<td align="center">
<div class="button">
<a id="ResetPass" class="buttonSearch">Open</a>
</div>
</td>
</tr>
</table>
below is the javascript function that find button and use to open popup box:
<script type="text/javascript">
var el=document.getElementById("ResetPass");
el.onclick = show_dialog2;
function show_dialog2() {
$( "#dialog" ).dialog();
}
</script>
Below is the div that have a form and controls on it:
<div id="dialog" style="visibility:hidden" title="Reset Password" type="hidden">
<%= form_tag({ controller: "settings", action: "reset_password"}, remote: "true" ) do |f| %>
<table style="text-align:center; vertical-align:top;">
<tr>
<td>
<p><%= label_tag(:name, "Name") %>
<%= text_field_tag(:name) %></p>
</td>
</tr>
<tr>
<td>
<div>
<%= text_field_tag( :newpassword, :placeholder => "New Password", :style => "text-align: center; BackColor:#e5e5e5; Width: 150px; ForeColor: Gray; Font-Size: Large;") %>
</div>
</td>
</tr>
<tr>
<td>
<div>
<%= text_field_tag( :reenterpassword, :placeholder => "Re-enter Password", :style => "text-align: center; BackColor: #e5e5e5; Width: 150px; ForeColor: Gray; Font-Size: Large;") %>
</div>
</td>
</tr>
</table>
<table>
<tr>
<td>
<%= submit_tag 'Submit', :id => "_button" %>
</td>
</tr>
</table>
<% end %>
</div>
But the problem is that when I enter values in the textboxes and click on submit button the popup box is not going , kindly help me waiting for your reply. Thanks.
Upvotes: 0
Views: 917
Reputation: 367
You could try to add the following code:
<script type="text/javascript">
$(document).ready(function() {
// '_button' is the Id of your submit button
$("#_button").click(function() {
$(this).closest("form").submit();
$("#dialog").dialog("close");
});
});
</script>
Upvotes: 0
Reputation: 3555
Are you using bootstrap 3 for the popup? If it it so, then u have to add the action to close the modal when the response has get successful result.
$('#dialog').modal('hide');
Hope it helps
Upvotes: 1