Don't update CMS preview on a CMS redirect

The CMS preview causes unnecessary browser processing by loading a URL
which should be considered "in transit" when a CMS redirect is set through
the X-ControllerURL HTTP header. The CMS history processing will
load this new URL, and cause a new preview URL to be loaded.

Fixes https://github.com/silverstripe/silverstripe-translatable/issues/158
This commit is contained in:
Ingo Schommer 2014-12-05 14:02:50 +13:00 committed by Will Rossiter
parent 88ac537e96
commit d5bb290b8e

View File

@ -326,7 +326,10 @@
* Update preview whenever any panels are reloaded.
*/
'from .cms-container': {
onafterstatechange: function(){
onafterstatechange: function(e, data) {
// Don't update preview if we're dealing with a custom redirect
if(data.xhr.getResponseHeader('X-ControllerURL')) return;
this._initialiseFromContent();
}
},