luis-almeida / filtrify

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

Somethings wrong with my filtify.js script in my scenario #68

Open kasandrica opened 6 years ago

kasandrica commented 6 years ago

(function ($, window, document, undefined) {

var defaults = {
    noresults: "No results match",
    hide: true,
    block: [],
    close: false,
    query: undefined,
    callback: undefined
};

function Filtrify(containerID, placeholderID, options) {

}; $(function () {

var post = $('ul#filtrifyContainer').find('li'),
ft = $.filtrify("filtrifyContainer", "placeHolder"),        
data = $(post).data(),
genre = $(post).data("genre"),
number = $(post).data("number");            

var Filter = function(category){
    $(post).each(function () {
        var attribute = $(this).data(category);             
        $(this).append('<a class="button small ' + category + '">' + attribute.split(',').join('</a><a class="button small ' + category + '">') + '</a>');              

      $('a.button').click(function (e) {
            e.stopImmediatePropagation(); 
            var buttonText = $.trim($(this).text()); 
          if($(this).hasClass('genre')){
            ft.trigger({genre: [buttonText]});
          }   
          if($(this).hasClass('number')){
            ft.trigger({number: [buttonText]});
          }   
       }); 
    });         
};

if(genre)Filter('genre')
if(number)Filter('number')      

});

Filtrify function are never executed in my scenario. Can anyone help me?