> For the complete documentation index, see [llms.txt](https://attr.sygnal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://attr.sygnal.com/sa5-elements/slider/slider-js-api-events.md).

# Slider JS API Events

### Receiving Slide Changed Events

To receive events from tab changes setup an SA5 callback with the `slideChanged` event. When called, it will contain the slider object, and the index of the new slide ( 0-based ).&#x20;

If you have multiple sliders marked with \[wfu-slider], you can assign a unique name, and access it through `slider.name`, as in this example;&#x20;

```html
<script>
window.sa5 = window.sa5 || [];
window.sa5.push(['slideChanged', 
  (slider, index) => {
    
    console.log("SLIDE CHANGED", slider.name, slider, index); 

    switch(slider.name) {
      case "demo1": // Demo 1 slide changed

        break;
      case "demo2": // Demo 2 slide changed

        break;
    }

  }]); 
</script>
```

### Manipulating the Slider <a href="#wfu-lightbox-captions-attribute" id="wfu-lightbox-captions-attribute"></a>

{% code overflow="wrap" %}

```typescript
sa5.push(['slideNextRequest', 
  (slider: any, index: any) => {
    console.log("SLIDE NEXT REQUEST", slider.name, slider, index); 

    // Example usage:
    // This will fetch the 3rd slide from the slider with the custom attribute 'wfu-slider="quiz"'
    const slide = this.getSlideByPosition(index + 1);
    if (slide) {
        console.log('Slide found:', slide);

      return this.checkRadioSelection(slide); 

    } else {
        console.log('Slide not found.');
    }

    return (index < 6); 
  }]); 
sa5.push(['slidePrevRequest', 
  (slider: any, index: any) => {
    console.log("SLIDE PREV REQUEST", slider.name, slider, index); 
    return (index > 0); 
  }]); 
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://attr.sygnal.com/sa5-elements/slider/slider-js-api-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
