Removing 'and' from filters only allowing 'or'

Hi there -

I'd like to remove the option for somebody to select 'and' when adding filters to a view (screenshot below).

I tried a couple different methods in javascript, but was unsuccessful. Any ideas?

Tony, 

Try this:

//declare a variable inside the Knack object for custom methods
Knack.fn = Knack.fn || {};

//global function to hide 'and'
Knack.fn.hideAndFromFilter = function(){
    Knack.$('.kn-filters-nav').click(()=>{
        Knack.$('#add-filter-link').click(()=>{
            Knack.$('.match.kn-select.kn-match-select option[value="and"]').remove();
        })
    })
}
$(document).on('knack-view-render.view_130', function(event, view, data) {
    Knack.fn.hideAndFromFilter(); //invoke the function inside of a view or render scene
});

Kelson
kelson@ksensetech.com
http://www.ksensetech.com/knack/

Thanks, Kelson! 

 

scene_58/views/view_130

Brad,

Knack has a version of jQuery that they modified so instead of $(selector) it is Knack.$(selector)

Tony, what is the key for the view and I will write the complete code for you to copy and paste.

Kelson
kelson@ksensetech.com
http://www.ksensetech.com/knack/

Hi Tony - 

That code is great! Unfortunately - I do need it to be view-dependent, as some of my views still need that filter option.

Thanks for responding - it's much appreciated!

Hey 371928693712 never seen Knack.$ used before - what does it return?  How did you know the selector you used to modify the filters?

Hi Kelson - 

 

Thanks for the reply. Unfortunately, when I try this, it's not working. I'm assuming it has something to do with the filter pop-up? Screenshot attached. ![](upload://9BkvlxHjTpGCQJZmYehxQnIMjmn.png)

Hi Tony, 

This should work for you to remove all 'and' from the filters. Be sure to place it inside your scene or view renders!

Knack.$('.match.kn-select.kn-match-select option[value="and"]').remove();

I tested it and it works great.

Best Regards, 

Kelson
kelson@ksensetech.com
http://www.ksensetech.com/knack/