Push the last URL + query when rendering a form's new markup.

Signed-off-by: Eric Riggs <ericriggs42@gmail.com>
This commit is contained in:
Eric Riggs
2018-03-14 03:21:06 -04:00
committed by Roberto Rosario
parent 53b47455d3
commit ed4f97cea7

View File

@@ -184,6 +184,7 @@ PartialNavigation.prototype.setupAjaxForm = function () {
* Method to setup the handling of form in an AJAX way.
*/
var app = this;
var lastAjaxFormData = {};
$('form').ajaxForm({
async: true,
@@ -199,6 +200,7 @@ PartialNavigation.prototype.setupAjaxForm = function () {
var url = $form.attr('action') || uriFragment;
options.url = url;
lastAjaxFormData.url = url + '?' + decodeURIComponent($form.serialize());
if ($form.attr('target') == '_blank') {
// If the form has a target attribute we emulate it by
@@ -229,6 +231,9 @@ PartialNavigation.prototype.setupAjaxForm = function () {
app.setLocation(newLocation);
} else {
var currentUri = new URI(window.location.hash);
currentUri.fragment(lastAjaxFormData.url);
history.pushState({}, '', currentUri);
$('#ajax-content').html(data);
}
}