How to bypass "refreshLayout.html" restriction for page

41 views Asked by At

In this line of the apostrophe-templates module it states that a jquery get call will set the req.xhr and as a result the refreshLayout.html template will be used, which means you don't get the entire page.

However this seems restrictive and we need a way to override it, because what if I actually just wanted the entire page for say animation purposes, or crawling purposes using jquery?

1

There are 1 answers

0
Tom Boutell On

As you know I am the lead developer of Apostrophe at P'unk Avenue.

It's easy to change the AJAX behavior. Just use a pageBeforeSend handler in any module to set a property in req.data and, in your refreshLayout.html, use that as the argument to extend.

// in any module
self.pageBeforeSend = function(req) {
  req.data.ajaxLayout = 'modulename:layoutname.html';
};

// in your refreshLayout.html
{% extend data.ajaxLayout %}

This is the same technique that allows your page templates or inner layout to extend either the outer layout or the ajax layout.