Home Forums Fusion Fusion Active State on AJAX Loaded Content

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  twin41 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47918

    twin41
    Participant

    Hello,

    Just finished getting our site together using your theme and it works nicely. Only thing we have had an issue with is the active state of the navigation when using the AJAX callbacks for loading page content. Can you take a look at this? I’ve disabled all caching and it hasn’t helped any. Not seeing any console errors. Or, could you point me to the file that the active state is being rendered from?

    http://www.twin41.com/

    Thanks,

    Twin41

    #47920

    Joshua
    Keymaster

    Good catch. The navbar class needs to be updated to fix the active class for the overlay menu. We’ll add this to the next update, but in the meantime you can add this code to your Custom Javascript to add the class on page change:

    	Barba.Dispatcher.on('transitionCompleted', function(currentStatus, oldStatus, container) {
    	  setHeaderSchemeData();
    		// Swap active link
    		$('#navbar .menu-item').removeClass('current-menu-item current_page_item active');
    		if (!window.location.origin) {
    		  window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
    		}
    		var link = currentStatus.url.split(window.location.origin)[1].substring(1);
    		$('#navbar').find('.menu-item a').each(function(){
    			if ($(this).attr('href') == '/' + link || $(this).attr('href') == currentStatus.url) {
    				$(this).parent().addClass('current-menu-item current_page_item active');
    			}
    		});
    	});
    #47929

    twin41
    Participant

    Thanks Joshua, that worked like a charm. Good stuff. Have a nice day.

    Steven

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.