CMS Development

gio-nab
Participant | Platinum Partner
Participant | Platinum Partner

Mobile navigation going crazy

SOLVE

Evening all!

 

We're having an issue on a site at the moment

 

When in mobile view, if we click the menu icon, the menu opens and closes about 5-6 times before staying open, and the same when we close the menu. It's really bizarre and only occurs on the blog list page, not on a specific post. 

 

I've noticed a number of errors in the console too which may be the cause of this, but I have no idea what they mean (see attached)consoleerrors.JPG 

 

Any help would be immensely appreciated, thank you!

1 Accepted solution
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Mobile navigation going crazy

SOLVE

@gio-nab - I believe it's your readingTime plugin. When I add this code to console, it waits about 15 seconds and then replicates your assets another 10 times. You should remove this toxic code and the readingTime Plugin altogether.

$('.total-words').each(function() {
    $(this).readingTime({
        wordsPerMinute: 200,
        readingTimeTarget: $(this).siblings('.time-to-read').find('.eta').addClass('abc'),
        wordCountTarget: $(this).siblings('.time-to-read').find('.words').addClass('babc'),
        remotePath: $(this).attr('data-file'),
        remoteTarget: $(this).attr('data-target')
    });
});

View solution in original post

0 Upvotes
6 Replies 6
dennisedson
HubSpot Product Team
HubSpot Product Team

Mobile navigation going crazy

SOLVE

would have to see the backend, but this looks pretty suspicious

Developer_Tools_-_Correvate_Blog_-_https___info_correvate_co_uk_blog_utm_campaign_Sample_-_My_first_inbound_campaign_in_HubSpot_utm_source_forum.png

tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Mobile navigation going crazy

SOLVE

@gio-nab - to go with @dennisedson answer, you need to go into the https://info.correvate.co.uk/hs-fs/hub/4447252/hub_generated/template_assets/1538064380090/CUST_Corr... file and add an if statement to the line that adds the mobile trigger:

//OLD
$(".hs-header-logo a").after('<div class="mobile-trigger"><i></i></div>');
//NEW
  if(!$('.mobile-trigger').length){
	 $(".hs-header-logo a").after('<div class="mobile-trigger"><i></i></div>');
  }
gio-nab
Participant | Platinum Partner
Participant | Platinum Partner

Mobile navigation going crazy

SOLVE

Thank you both for getting back to me.

@tjoyce, I've tried your suggestion and it doesn't look to have worked unfortunately. I'm not sure if it's a caching issues (the link you shared was -main.min.js, I only have access to -main.js via hubspot). 

 

Do you still see it on your side? I cleared cache / tried multiple devices.

 

Thank you so far!

0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Mobile navigation going crazy

SOLVE

@gio-nab - You appear to have a deeper issue where all of your header assets are being duplicated about 10 times. This is causing jquery to be added 10 times which is running all of your triggers 10 times. If we can find a way to fix that, it will increase your page load times tremendously as well as fix all the bugs.

deep.png

0 Upvotes
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Mobile navigation going crazy

SOLVE

@gio-nab - I believe it's your readingTime plugin. When I add this code to console, it waits about 15 seconds and then replicates your assets another 10 times. You should remove this toxic code and the readingTime Plugin altogether.

$('.total-words').each(function() {
    $(this).readingTime({
        wordsPerMinute: 200,
        readingTimeTarget: $(this).siblings('.time-to-read').find('.eta').addClass('abc'),
        wordCountTarget: $(this).siblings('.time-to-read').find('.words').addClass('babc'),
        remotePath: $(this).attr('data-file'),
        remoteTarget: $(this).attr('data-target')
    });
});
0 Upvotes
gio-nab
Participant | Platinum Partner
Participant | Platinum Partner

Mobile navigation going crazy

SOLVE

Thank you @tjoyce for all of your help! 

This looks to be the culprit of the issue indeed. 

 

If I remove it, it removes the number and leaves the "read" text behind - so I'll have to remove it elsewhere in the template (not an issue!). 

 

Thank you for all of your help 🙂