Reputation: 1274
I am in show view of a controller and if a user clicks on a link, a popup window with a form is displayed. If the user clicks "Submit", the form is submitted via ajax to a custom "action" in the same controller. In the action.js.erb partial I have the following code:
window.opener.location.reload();
window.close();
It works fine, but the whole show view page is reloaded. And I'd like just to have the focus back and write some div updates in the js.erb partial.
Upvotes: 1
Views: 5451
Reputation: 674
In the associated action.js.erb file, add the following code.
function hideDialog() {
var $dialog = $('#dialog_area');
if ($dialog.is(':visible')) {
PageOverlay.hide();
$dialog.hide();
}
return this;
};
Upvotes: 0
Reputation: 5961
Instead of calling from helper , close the window on onsuccess event of Ajax.
success: function(g) {
window.close(); OR $('#popup_id').hide();
$('#div_id').html("Write message or other response form your action").
}
Upvotes: 1
Reputation: 3428
Use jquery to hide it once completed.
$('#popup_wrapper_id').fadeOut();
Upvotes: 1