luis-almeida / filtrify

Beautiful advanced tag filtering with HTML5 and jQuery
Other
642 stars 113 forks source link

Hide Empty Tags #33

Closed stardisblue closed 9 years ago

stardisblue commented 10 years ago

Hello,

What can i do to hide an empty tag, It's for multiple selection, for exemple. When i select Genre : action what i need to do with the empty tags in the actor category. I guess it's not so difficult, just need to hide the tags with count 0.

Thank you. Sorry if my english is bad, i'm french.

vinny75 commented 10 years ago

replace rewriteFields:

    Filtrify.prototype.rewriteFields = function () {
        var field;
        for ( field in this._fields ) {
            this._menu[field].tags
                .children()
                .each( this._bind( function( index, element ) {
                    var tag = ( element.textContent || element.innerText ),
                        count = this._fields[field][tag] === undefined ? 0 : this._fields[field][tag];

                    element.setAttribute("data-count", count );

                        if ( count === 0 ) {
                            $(element).addClass("ft-no-items-hidden");
                        } else {
                            $(element).removeClass("ft-no-items-hidden");
                        };  
                }, this ) );
        };
    };  

and .ft-hidden

.ft-hidden, .ft-no-items-hidden { display: none !important; }