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.

Add onClick callback for slides

See original GitHub issue

Add onClick callback (optional) for when individual slides are clicked…

I’m basically achieving this right now by registering a click handler for each slide in the onInit callback:


onInit: function(slick){
    slick.$slides.each(function(index, slide){
        console.log('slide #' + index + ' has been clicked!');
    });
}

This seems to work, but it would be nice if there was an easier way to achieve this…

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
kenwheelercommented, May 7, 2014

You can do this like:

$('.slick-slider').on('click', '.slick-slide', callBack);
0reactions
codernikcommented, Nov 5, 2019

This works well $(‘#slider_co .slick-slide’).on(‘click’, function (e){ let slideClicked = $(e.currentTarget).attr(“data-slick-index”); console.log(slideClicked); });

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript - href vs onclick for callback function on Hyperlink
I have a webform where the user can add and remove items and I put the onclick in the href of the links...
Read more >
Click Events - Embla Carousel
Adding click events to your slides with React is straightforward. We'll create a onSlideClick function wrapped in a useCallback and add that click...
Read more >
Simple Triggers | Apps Script - Google Developers
Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs. Simple triggers are a set of...
Read more >
View.OnClickListener - Android Developers
android.app.appsearch.observer. Overview. Interfaces. ObserverCallback. Classes. DocumentChangeInfo · ObserverSpec · ObserverSpec.Builder · SchemaChangeInfo.
Read more >
ASP.NET Core Blazor event handling - Microsoft Learn
Wire up the custom event with the event arguments by adding an ... <p> <button @onclick="OnClickCallback"> Trigger a Parent component method ...
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