A
A
Aerotid2019-09-19 17:24:16
CMS
Aerotid, 2019-09-19 17:24:16

CS-Cart + Barba.js?

Hello.
I use barba.js in my projects to navigate between pages without reloading. First experience with CS-Cart.
The problem is that it is necessary to use the scripts of this platform for the operation of the online store (adding goods to the cart, favorites, comparison, placing an order).
Each platform file is connected separately, they all lie in the barba.js container and dynamically change during transitions between pages, but are not initialized.
I saw only one solution with the launch of built-in scripts - the eval function.

Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container) {
    var js = container.querySelector("script");
    if(js != null){
        eval(js.innerHTML);
    }
});

A rather dangerous solution, which, in addition, duplicates functions if you return to a page with the same scripts.
Is there an adequate solution to this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question