Skip to content

Commit

Permalink
MINOR Skip processing in CMS on empty ajax responses, as they're usua…
Browse files Browse the repository at this point in the history
…lly a pseudo redirect (via X-ControllerURL)
  • Loading branch information
chillu committed Apr 5, 2012
1 parent e01b0aa commit aebbb10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions admin/javascript/LeftAndMain.Content.js
Expand Up @@ -83,11 +83,11 @@
* (XMLHTTPRequest) xmlhttp
*/
loadForm_responseHandler: function(oldForm, html, status, xmlhttp) {
if(!html) return;

if(oldForm.length > 0) {
oldForm.replaceWith(html); // triggers onmatch() on form
}
else {
} else {
$('.cms-content').append(html);
}

Expand Down Expand Up @@ -199,6 +199,8 @@
*/
submitForm_responseHandler: function(oldForm, data, status, xmlhttp, origData) {
if(status == 'success') {
if(!data) return;

var form, newContent = $(data);

// HACK If response contains toplevel panel rather than a form, replace it instead.
Expand Down
4 changes: 4 additions & 0 deletions admin/javascript/LeftAndMain.js
Expand Up @@ -227,6 +227,10 @@ jQuery.noConflict();
headers: headers,
url: state.url,
success: function(data, status, xhr) {
// Pseudo-redirects via X-ControllerURL might return empty data, in which
// case we'll ignore the response
if(!data) return;

// Update title
var title = xhr.getResponseHeader('X-Title');
if(title) document.title = title;
Expand Down

0 comments on commit aebbb10

Please sign in to comment.