arvgta / ajaxify

Ajaxify - The Ajax Plugin
https://4nf.org/
274 stars 124 forks source link

From root to folder and folder in folder doesn't work in Ajaxify #237

Closed Allmedialab closed 1 year ago

Allmedialab commented 1 year ago

Hi Arvind,

Still see a problem with pages in a folder outside the root of the website for example: folder > folder > page.html etc. <script src="../../js/ajaxify.min.js"></script> etc.

Error: Uncaught SyntaxError: Identifier 'Ay' has already been declared (at ajaxify.min.js:1:1

Hard loading (refreshing the page) such a page in a location outside the root in Chrome browser shows nothing in the console not even Äjaxify loaded.... And Ajaxify stops working.

Regards & Thanks,

David

arvgta commented 1 year ago

Hi David,

You should always use the same path to Ajaxify everywhere. The error you're observing means that Ajaxify was loaded twice... That is because delta loading thinks that they are two different files.

Thanks and regards, Arvind

David Akinci @.***> schrieb am Mo., 27. Feb. 2023, 10:32 AM:

Hi Arvind,

Still see a problem with pages in a folder outside the root of the website for example: folder > folder > page.html etc.

etc. Error: Uncaught SyntaxError: Identifier 'Ay' has already been declared (at ajaxify.min.js:1:1 Hard loading such a page in a location outside the root in Chrome browser shows nothing in the console not even Äjaxify loaded.... Regards & Thanks, David — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Allmedialab commented 1 year ago

I'm afraid that doesn't solve the problem, when I replace my Ajaxify script links with cdn links I get exactly the same problem.

It is a bug that I reported a year ago with the use of a index page in the root leading to languages folder with webpages inside like: index.html click to > nl > contact.html

For the time being I created a redirect but now I need to use sub folders like: index.html clik to > nl > hotels > nicehotel.html

arvgta commented 1 year ago

Hi David,

Do you have a link to a test site?

Thanks and regards, Arvind

David Akinci @.***> schrieb am Mo., 27. Feb. 2023, 11:01 AM:

I'm afraid that doesn't solve the problem, when I replace my Ajaxify script links with cdn links I get exactly the same problem. It is a bug that reported a year ago with the use of a index page in the root leading to languages folder with webpages inside like: index.html click to > nl > contact.html

— Reply to this email directly, view it on GitHub https://github.com/arvgta/ajaxify/issues/237#issuecomment-1446036068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUYBGEXBBTE4T6HUSIEHYLWZR3PDANCNFSM6AAAAAAVJE2GNI . You are receiving this because you commented.Message ID: @.***>

Allmedialab commented 1 year ago

Hi Arvind,

This is the link to the test site: https://yourweblab.nl/

It opens with the Dutch index.html page in the root and from there you can go to the nl folder or the en folder.

The problem: When clicking from the root Home to for example to Wij in the nl folder or any other page outside the root Ajaxify can't follow it anymore and gives errors in the console.

To show the issue: Go to Wij and staying on Wij refresh the browser, now stay away from Home and click to any other page in the nl folder. As long as you stay on the same level there is no problem and Ajaxify is working fine. A second test is go to the English version of the website: https://yourweblab.nl/en/ Now you are in the en folder on one level and everything works including Home that is in that same folder.

The bigger problem: At the moment I'm working on a 600 plus pages website with folders in folders like: from Home I have to click to for example Hotels > Nice little hotels > Nice-little-hotel.html this is confusing Ajaxify and it looses track stops working and shows errors in the console.

With the jQuery Ajaxify this was no problem: https://www.onderdepoort.be/ Here you can click from the root Home to Over Ons that is located in the nl folder and so on.

Hope this is enough information to start looking for a solution.

Example of a one level website working perfect with the latest Ajaxify: https://www.athene-gulpen.nl/

Regards & Thanks,

David

JayeshLab commented 1 year ago

Hi Arvind,

I have created a pull request https://github.com/arvgta/ajaxify/pull/238 for this issue.

Issue: Currently when a user navigates from home page at root level to page under folder level it Ajaxify throws an error. Error: Uncaught SyntaxError: Identifier 'Ay' has already been declared (at ajaxify.min.js:1:1, unnamed

As it try to load Ajaxify library and Ajaxify init library again, ajaxify consider it as different script file because script src relative path is different at root index.html <script src="js/ajaxify.js"></script> and folder level page nl/over-ons.html <script src="../js/ajaxify.js"></script>. It is also true with all the script and css path as relative path changes when navigating from root to folder and folder to subfolder level pages

Fix: Instead of mantaining attribute for script/link tag. Ajaxify fix gets the full path of script/link tags. e.g. https://www.yourweblab.nl/js/ajaxify.js which makes ajaxify correctly does the diff checks while navigating between pages.

arvgta commented 1 year ago

Hi David and Jayesh,

Thanks for this contribution, which I just tested against 4nf.org and works fine there as well... The new logic will be available from version 8.2.9...

Regards, Arvind