mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-11 10:30:58 +00:00
output template errors on preview into the preview window - fixes #2
This commit is contained in:
parent
3eb18eac64
commit
aae4bf3bf1
1 changed files with 17 additions and 5 deletions
|
|
@ -257,10 +257,12 @@ $(function() {
|
|||
/* Set up behaviour of preview button */
|
||||
$('#action-preview').click(function() {
|
||||
var previewWindow = window.open($(this).data('placeholder'), $(this).data('windowname'));
|
||||
$.post(
|
||||
$(this).data('action'),
|
||||
$('#page-edit-form').serialize(),
|
||||
function(data, textStatus, request) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $(this).data('action'),
|
||||
data: $('#page-edit-form').serialize(),
|
||||
success: function(data, textStatus, request) {
|
||||
if (request.getResponseHeader('X-Wagtail-Preview') == 'ok') {
|
||||
previewWindow.document.open();
|
||||
previewWindow.document.write(data);
|
||||
|
|
@ -271,7 +273,17 @@ $(function() {
|
|||
document.write(data);
|
||||
document.close();
|
||||
}
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
/* If an error occurs, display it in the preview window so that
|
||||
we aren't just showing the spinner forever. We preserve the original
|
||||
error output rather than giving a 'friendly' error message so that
|
||||
developers can debug template errors. (On a production site, we'd
|
||||
typically be serving a friendly custom 500 page anyhow.) */
|
||||
previewWindow.document.open();
|
||||
previewWindow.document.write(xhr.responseText);
|
||||
previewWindow.document.close();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue