WordPress.org

Ready to get started?Download WordPress

Forums

Advanced AJAX Page Loader
[resolved] Retrieve Body Class from DATAA (7 posts)

  1. zumajoe
    Member
    Posted 1 year ago #

    Trying to grab the class names from the loaded content's Body Class (so that I can replace the body class on the current page with what was loaded), I've come up with the following but cannot seem to get this to work:

    classes =  jQuery(dataa).find('body').attr ("class").split(' ');
    
    for(var i=0; i<classes.length; i++){
     console.log(classes[i]);
    }

    Anyone have a clue?

    http://wordpress.org/extend/plugins/advanced-ajax-page-loader/

  2. jmeffre
    Member
    Posted 1 year ago #

    I'm looking for something like that to change the body class ... did you find the solution ? Thx

  3. MikeSV
    Member
    Posted 1 year ago #

    Looking for a solution to this too. Body classes are EXTREMELY important for my builds.

  4. Courtney Fantinato
    Member
    Posted 1 year ago #

    Any update on this? I need this as well.

    Many themes rely on the different body classes generated by WordPress, they should be able to be updated to the current page...

  5. Courtney Fantinato
    Member
    Posted 1 year ago #

    My work around is to put the WP generated body classes from body_class() on a div inside the #site-wrap div I am using in the "Content Element ID" setting.

    Note that anything (such as classes) on the element you're using for the "Content Element ID", and outside of it doesn't change.

    So if possible for some of you, it is easier to move body_class() from the body element inside what is actually being "refreshed" on the page so that it gets updated and can be used for CSS and PHP, rather than trying to change anything on the body tag.

  6. azharpratama
    Member
    Posted 9 months ago #

    You can't just use jQuery on "dataa" since it's not yet a DOM object of browser. The easiest way is to use workaround given by Courtney or parse the jqXHR string using .split function (hard way) which is time consuming :)

  7. Dean Williams
    Member
    Plugin Author

    Posted 9 months ago #

    You need to wrap your content area with a class or id that is constant, you should not ever be binding to the body tag as this will reload everything.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic