Barba: Slider not iniating

Created on 6 Nov 2017  路  5Comments  路  Source: barbajs/barba

I'm using a slider and it won't initiate unless I reload while on the page. A alert will run but the script won't start until I reload the page.

I've tried embeding the javascript on the page on ready().

I've tried embed the javascript on page ready.
Barba.Dispatcher.on('newPageReady', function() { ..slider do things..

This also didn't work. Only on load will the slider
var work = Barba.BaseView.extend({
namespace: 'work',
onEnter: function() {
},
onEnterCompleted: function() {
$('.portfolio-slider').slick({ ....

Any help would be much apreciated.

Most helpful comment

Try using Barba.Dispatcher.on:

Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container, rawHTML) {
    $('.portfolio-slider').slick({
        ...
    });
});

All 5 comments

Try using Barba.Dispatcher.on:

Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container, rawHTML) {
    $('.portfolio-slider').slick({
        ...
    });
});

@kjbrum Thank you very much. You saved my life!

Where di you find that? Do they have mentioned it on barbajs docs? I couldn't find.

@dmcshehan It's listed on the events page. http://barbajs.org/events.html

I have another question. When I use Barba js on my website, php WordPress functions like "body_class()" isn't working. I think it's because ajax. What do you suggest?

This is the website I'm building
http://labnero.mentall.be/

@dmcshehan add body_class on your barba-container, instead of the body.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kram08980 picture kram08980  路  3Comments

gitgudcameron picture gitgudcameron  路  3Comments

3oax picture 3oax  路  4Comments

S1SYPHOS picture S1SYPHOS  路  3Comments

Mexikaner9 picture Mexikaner9  路  3Comments