3D FlipBook - Using a SPA (like barba.js)

k***d@gmail.com
2021-03-22
2021-03-27

Hi,

I'm using barba.js which means the the first time I load a page on my site, the book works fine. But when I click through to any other page with a book, the book doesn't load.

The flipbook javascript files are still included in the second page, but it seems that the flipbook just needs to be triggered.

Is there a JS function I can use that will trigger the flipbook to load, assuming the "_3d-flip-book" element/container is already in place?

Thanks

Replies

a***r@3dflipbook.net
2021-03-22
2021-03-22

Hi, reexecute client.min.js

k***d@gmail.com
2021-03-22
2021-03-22

Ok, I will try that, thanks

k***d@gmail.com
2021-03-23
2021-03-23

I've done what you suggested. I've also added alert(); to the client script to make sure it's definitely re-executing, and it is.

However, the variable FB3D_CLIENT_LOCALE (inside the #3d-flip-book-client-js-extra element) doesn't change after client.min.js has been re executed. Any idea?

Thanks

a***r@3dflipbook.net
2021-03-23
2021-03-26

FB3D_CLIENT_LOCALE is script localization for client.min.js it is defined after parsing all shortcodes on the back end.

k***d@gmail.com
2021-03-23
2021-03-23

Ok, thanks.

Currently the book will only work on the first instance. If I navigate to a second book page (ie. with a different shortcode), it will show "no items found", even though the book will work on this page if I refresh and start from here. I just assumed FB3D_CLIENT_LOCALE was the cause of this as it appears to keep the information of the previous book, even after a redirect.

a***r@3dflipbook.net
2021-03-23
2021-03-23

Could you write a link to your page?

k***d@gmail.com
2021-03-23
2021-03-28

removed Then Go to Book B Check console log for comments Thanks

k***d@gmail.com
2021-03-25
2021-03-25

Hi, can you please let me know when you have had a look, so I can remove the link from the previous comment thanks

k***d@gmail.com
2021-03-25
2021-03-25

?

a***r@3dflipbook.net
2021-03-26
2021-03-26

FB3D_CLIENT_LOCALE is script localization for client.min.js, it is defined after parsing all shortcodes on the back end.

if you look for FB3D_CLIENT_LOCALE in page A elements - you will find FB3D_CLIENT_LOCALE definition for page B only - so your Ajax does not fetch the scripts localization wp_localize_script('3d-flip-book-client', 'FB3D_CLIENT_LOCALE',[...]); .

Enter in console FB3D_CLIENT_LOCALE, see jsData - there is only 38 post. After ajax FB3D_CLIENT_LOCALE is not redefined.

Also you can somewhere in common for all Ajax pages insert

[3d-flip-book mode="link-lightbox" id="38"][/3d-flip-book]
[3d-flip-book mode="link-lightbox" id="39"][/3d-flip-book]

this includes data in FB3D_CLIENT_LOCALE

k***d@gmail.com
2021-03-28
2021-03-28

Thanks, I'll give that a try

k***d@gmail.com
2021-03-29
2021-03-29

I couldn't get it to work so I ended up loading them through a separate iframe. Eg. When I need to load any new book dynamically I just change my iframe src so it points to a new page that only has the headers, book shortcode and footer.

a***r@3dflipbook.net
2021-03-31
2021-03-31

well, this also simple and should work)

Log In to leave a comment