app/assets/javascripts/trestle/components/_form.js in trestle-0.8.12 vs app/assets/javascripts/trestle/components/_form.js in trestle-0.8.13
- old
+ new
@@ -20,13 +20,13 @@
.on('ajax:complete', function(e, xhr, status) {
// Reset submit buttons
$(this).find(':submit').prop('disabled', false).removeClass('loading');
$(this).removeData('trestle:submitButton');
- var contentType = xhr.getResponseHeader("Content-Type");
+ var contentType = (xhr.getResponseHeader('Content-Type') || '').split(';')[0];
- if (contentType && contentType.split(";")[0] == "text/html") {
+ if (contentType == 'text/html') {
if (/<html/i.test(xhr.responseText)) {
// Response is a full HTML page, likely an error page. Render within an iframe.
var context = $(this).closest('[data-context]');
var iframe = $("<iframe>").addClass('error-iframe').get(0);
context.html(iframe);
@@ -41,10 +41,10 @@
$(Trestle).trigger('init', context);
// Focus the correct tab
Trestle.focusActiveTab();
}
- } else {
+ } else if (contentType == 'text/plain') {
// Assume an error response
var title = xhr.status + " (" + xhr.statusText + ")";
Trestle.Dialog.showError(title, xhr.responseText);
}
})