djax
djax copied to clipboard
Auto Update HTML Head Elements
Would be a good feature to have djax update all HTML Head Elements after ajaxing a new page.
title element meta description meta keywords ( optional ) body class Pjax does this out the box and I would assume this would as well. with exception to changing body class
@hyperking agreed, this is definitely on the up and coming list. Not sure when I will have time to spend next but these changes should be pretty simple, I'd be happy to accept a pull request.
Im not to savvy with github pull request, but here is a gist i came up with that achieves what I'm looking for. https://gist.github.com/hyperking/9177864#file-djax-body-class-update
Thanks for sharing @hyperking but this looks like it's referencing some globally defined functions that aren't even included in the gist content.
I think this is at most two new lines of code to grab the page title and meta description, maybe a third for keywords, placed in the right spot of the djax source. No worries if you aren't comfortable forking and opening a PR, this is high on my list of priorities the next time I find some time to update.
which functions? Im using animate css and transit jquery plugin.
Hi beezee, I am also looking around for a way to update the page title and body class. What do you mean - will this be in some of the next updates? .. You wrote about it ;-) Thank much! p ".. this is high on my list of priorities the next time I find some time to update..... "
@infosion have u could try my gist method?
at first it didnt work for me - I
ll give it another try tomorrow.
@infosion @beezee I updated my gist to reflect the example you provided using DOM replacement callbacks.
I defined the body class value based on the page title value. Assuming most sites format the title attribute as "Site Name|Page Name".
hope that helps. also, you could replace
var pageTitle = window.location.pathname.split('/')[1];
from the gist however, for landing pages the body class will be empty.
Has there been any progress with this @beezee? All I really need is a way to reload the body classes as I'm working with a Drupal site where flexibility is not always possible so sometimes I have to rely on the body classes for styling purposes. The method suggested by hyperking could work but it is not a bulletproof as I would like.
Any help would be much appreciated!