Refreshing body classes using Djax/Pjax

I’m using Djax as a way of integrating Pjax on my site. For the most part it works great, but one feature I would like to integrate is refreshing body classes after a load event. The issue has been discussed here and here but no real solution has been suggested (although the author suggests it should be easy to do).

Using the djaxLoad function you can work with some of the data from the requested page but I’m unsure if this contains the body classes.

As a convenience, the data object passed with the event contains the
requested url, the page title for the requested page, and the contents
of the requested page as a string. Use something like the following
code to work with the response as a jQuery object

$(window).bind('djaxLoad', function(e, data) {
    var responseObj = $('<div>'+data.response+'</div>');
    //do stuff here
});

If anyone has any ideas I’d greatly appreciate it. I’m also open to other options other than Djax/Pjax if there is a simpler solution I am overlooking.


Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.