Problems with Search Friendly URL's specifically Tabs

GK User
Sun Aug 23, 2015 7:50 pm
I have been having problems with this template affecting how some components work, specifically I spent some time tracking down a bug that cause Community Builder to break when using Search Friendly URL's.
With some help from the CB support team the issue was traced to some template JS code that was wrongly re-writing some URL's containing the # tag.
The code was about lines 113 - 130 in the file gk.scripts.js. This is labeled smooth anchor scrolling and seems to be the homepage anchor feature that I did not need. My solution was to comment out this function.
I think this issue has been causing me many unwanted page loads but the above was the only fatal one I had to fix.
I share to see if there is a better fix and possibly to help others.
User avatar
Junior Boarder

GK User
Mon Aug 24, 2015 6:38 am
This code allows to smooth scroll to any module using #tag in url. I'm wondering how could it cause problems. Could you please describe it more specific?
User avatar
Moderator

GK User
Tue Aug 25, 2015 2:13 am
Sure this is what I got from CB group and they were right once that code was removed it solved that and seems to have solved others.
Hello Stephen,
I have reviewed your issue and it's caused by your Joomla template. Your Joomla template is loading the below JS file.

/templates/gk_ncadd/js/gk.scripts.js

In that JS file is the below binding of all <a elements with a hash in their URL on line 113.

jQuery('a[href*="#"]').on('click', function (e) {

Inspecting the code of it it's taking over all <a elements on your entire site using a hash URL to cause a window.location change. The tabs use a hash to do content jumping and are <a elements. So that jQuery usage will break our tabs. Your issue is not with CB, but with aggressive JS provided by your template. With that said you need to contact your template developer and have them fix their broken JS or manually remove lines 113 - 131 in the above file. There's also risk of other jQuery present that could cause other issues, please review your templates JS carefully.

A JS triggered navigation change is easy to catch in the developer console if you'd like to confirm this as well. Press F12 to open the developer console then click the Network tab. Next ensure you're on profile edit of another user. Then ensure it's set to preserve the log. Now click a tab to cause the navigation. You'll then see under "Initiator" or "Source" as to what triggered the navigation change to a GET request to the userdetails page. This will also tell you what line of code in the JS file triggered the navigation change. In this case it's like 129 of the above script.
Now for reference the link in question for a tab change on CB is: /cb-profile-edit/userdetails#cbtabpane11 which fits your js tests so gets changed causing a problem.
I hope this helps, I feel a fool for not spotting this issue but never thought it would be a template issue, so was not looking for this type of error. Oh the joys of being an integrator of all these pieces!
User avatar
Junior Boarder

GK User
Fri Aug 28, 2015 6:39 am
Thanks for quoting the message. I'll provide it to tour devteam.
User avatar
Moderator


cron