1rosehip / jplist-es6

jPList is a JavaScript library for sorting, pagination and filtering of any HTML structure like DIVs, UL/LI, tables, etc.
https://www.jplist.org/
MIT License
83 stars 39 forks source link

Disable buttons not matching current selection #27

Closed triograf closed 6 years ago

triograf commented 6 years ago

Hi is it possible to add a class to those buttons (or make them disabled) not matching a current selection? Let’s say i have two path filter controls in my application.

The first one says: color red, color blue, color green. The second sasy: shape triangle, shape circle, shape rectangle.

When i click e.g. on »color red« all buttons in the second row should be disabled that do not match »color red« too.

That would make the »no results found« obsolete as you give the visitor a hint what ist matchable and what is not.

triograf commented 6 years ago

Hi, i tried to solve »my problem« with the JPlist State Event API method with some success. However when using something like this (mentioned here: ([https://github.com/1rosehip/jplist-es6/issues/25])

counterControlElement.addEventListener('jplist.state', (e) => {

           if(e.jplistState.filtered.length === 0){
        //DO SOME LOGIC 
       }

        }, false);

LOGIC only happens when all elements are hidden. Is there a way to get a API method for each counter control? Like so:

for (var i = 0, len = el.counterControl.length; i < len; i++) {

                el.counterControl[i].addEventListener('jplist.state', function (e) {

                    if (e.jplistState.counter.length === 0) {
                        //DO SOME LOGIC 
                    }

                }, false);

            }

Thanks in advance … I would also pay for something like this. Best wishes …

triograf commented 6 years ago

Nevermind this issue. Found a very dirty, hacky solution in combination with counter control, a span with an updating class in data-format=" and State Event.