chromawoods / instaFilta

jQuery plugin for performing in-page filtering
MIT License
41 stars 12 forks source link

Multiple filters, same target #9

Open lroggen opened 9 years ago

lroggen commented 9 years ago

Great jQuery plugin! I'm having a slight issue though. I'm trying to target target the same table rows with two different InstaFilters, one a checkbox and the other a text input field. It works well if I use one or the other but if I try to check a box and enter text, all of the td's in my table row disappear.

Have you seen anything like this before? Can I even use two filters on the same targets?

    $('#task-search').instaFilta({
        scope: '.wrapper',
        targets: 'tr.task',
        markMatches: true
    });

    var instaFilta = $('#user-search').instaFilta({
        scope: '.wrapper',
        targets: 'tr.task'
    });

    var $userCheckboxes = $('.user-checkbox');
    $userCheckboxes.on('change', function() {
        var checkedCategories = [];
        $userCheckboxes.each(function() {
            if ($(this).prop('checked')) {
                checkedCategories.push($(this).val());
            }
        });
        instaFilta.filterCategory(checkedCategories);
    });

Check Box: three Text Input and initial view: one Result of using both at once: two

chromawoods commented 9 years ago

Just to be clear of the expected result: So if you first check a checkbox, then start typing in the search field, the expected behavior is that the filtering process should only be applied to the remaining visible hits, right? So it should be like a filter-on-filter kind of thing? So any filtering process should ever only apply to whatever result is currently remaining.

I have thought about this feature before and I would like to implement it. I don't think you can do it currently. I'm going to have to look into it and get back.

lroggen commented 9 years ago

You are correct, the filter would limit everything to the checked item(s) and the search string. If it is not too complex, it would be a great feature!

deutschehandarbeit commented 9 years ago

I am really looking forward to this.

brt-tito commented 9 years ago

Yes, me too. That's a thing I really can use.

chromawoods commented 9 years ago

Right, beginning to feel the heat surrounding this issue. :fire:

I assure you all that I am considering this feature. Just not sure about the flow of things. I don't want to break any current functionality either. At the moment, the plugin kinda requires a text field as its main element, but it would be nice if this could be made more flexible.