Previous and Next button status/class change

Previous and Next button status/class change

tutaqqtutaqq Posts: 5Questions: 2Answers: 0

Hello,

is it possible to detect a change of class (or status) from enabled to disabled, and vice-versa for previous and next pagination buttons? I can see that class 'disabled' is added when disabled, and tabindex changes from 0 to -1, but how to detect the change? Thank you.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    I don't think you can detect a change of class, but you could trigger on draw, that would be the only time those classes are modified.

    Colin

  • tutaqqtutaqq Posts: 5Questions: 2Answers: 0

    Thank you. I can scan a change with MutationObserver, but hoped for some 'cleaner' solution.

    var target = $( "#example_paginate" )[0];

    var observer = new MutationObserver(function(mutations) {
    if($("#example_next").attr('tabindex')==-1)
    // do something if next disabled
    if($("#example_previous").attr('tabindex')==-1)
    // do something if previous disabled
    });
    var config = { attributes: true, childList: true, characterData: true };
    observer.observe(target, config);

This discussion has been closed.