question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom paging stops working after version 1.8.0

See original GitHub issue

Adding a custom paging stops working after version 1.8.0.

====================================================================

Working CodePen

Working Codepen, but if I change to version 1.8.1 or higher, it stops working.

====================================================================

Steps to reproduce the problem

  1. Set up slider as recommended in docs.
  2. Add a data-title attribute on the slider items
  3. Add customPaging like so: customPaging : function(slider, i) { var title = $(slider.$slides[i]).data('title'); return '<a class="pager__item">'+title+'</a>'; }

====================================================================

What is the expected behaviour?

Dots should get the data-title information add replace the dots.

====================================================================

What is observed behaviour?

“undefined” gets output.

====================================================================

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
drdogbot7commented, Aug 2, 2019

What’s happening seems to be that in recent* versions the target “slide” element is wrapped in 2 additional divs. In earlier versions the “Slick-slide” class was just added directly to the target “slide” element.

In the latest version of Slick Carousel, if you want to access data attributes on the original slide, you just need to traverse the DOM by 2 levels.

So here’s the original example:

customPaging: function(slider, i) {
    var title = $(slider.$slides[i]).data('title');
    return '<a class="pager__item">'+title+'</a>';
}

the fix would be:

  customPaging : function(slider, i) {
        var title = $(slider.$slides[i].children[0].children[0]).data('title');
        return '<a class="pager__item">'+title+'</a>';
}

or in vanilla JS:

  customPaging : function(slider, i) {
        var title = slider.$slides[i].children[0].children[0]).dataset.title;
        return '<a class="pager__item">'+title+'</a>';
}

https://codepen.io/drdogbot7/pen/wVrGmB

  • I actually had mixed results with versions 1.8.0 and 1.8.1. I suspect that some of the CDN versions are slightly out of sync with the NPM versions. ¯_(ツ)_/¯
1reaction
ulimccommented, Jun 4, 2018

Hi, this seems to work for me with version 1.9.0:

slideTitle = $(slider.$slides[pageIndex]).find('.slick-slide').data('slide-title');

I have an attribute called “data-slide-title” on the slick-slide and I had to report that text to the bullet button. I found out that an additional <div> is injected for some reason I did not understand and didn’t have time to 😃 So i just called a .find(‘.slick-slide’) function to get the job done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom pagination not working - Magento Stack Exchange
This is your problem. In the template you have this line: $data = Mage::getModel('brand/brand')->getCollection();.
Read more >
custom paging slider missing config file for react.js
It looks like the component just wants a base url from a config file. The baseUrl needs to be the url path of...
Read more >
After upgrading from version 2011 to 2013 custom paging has ...
I have client-side grid inherited from RadGrid. It was fully functional, but after upgrade to the newest Telerik version it stopped working ......
Read more >
Navigation | Android Developers
Navigation Safe Args has upgraded the Android Gradle Plugin dependency to rely on 7.0.4 , dropping compatibility for AGP versions before 7.0 ....
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
Bug:1523 - "[IDEA] Offload work by distributing trivial ebuild maintenance ... Bug:179497 - "vm-pop3d crashes when checking mail and writes garbage to mail ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found