mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.68k stars 552 forks source link

chosen-selectpicker + unique-filter = javascript error #950

Open jakeb16 opened 2 years ago

jakeb16 commented 2 years ago

I started using QueryBuilder as a starting point for a custom control I am working on. It's working great and I have been able to do most of what I hoped, however I justed noticed a problem with using chosen-selectpicker + unique-filter

I created a little demo (based on someone elses demo) to illustrate the problem.
https://codepen.io/jakeb16/pen/bGLRjPQ

If you click "add a rule:" then change the first rule Name to Category (you shouldn’t even be able to do this since category is marked as unique) You get the JavaScript error (Uncaught UndefinedFilterError: Undefined filter "null")

If you remove the chosen-selectpicker plugin it works fine.

I'll look and see if I can figure out what's causing this but thought I would post to see if anyone else has an idea.

jakeb16 commented 2 years ago

I had the wrong code pin linked its here https://codepen.io/jakeb16/pen/bGLRjPQ

jakeb16 commented 2 years ago

Updating applyDisabledfilters with this at the end seems to fix the issue `// update Selectpicker

    else if (self.settings.plugins && self.settings.plugins['chosen-selectpicker']) {
        self.$el.find(QueryBuilder.selectors.rule_filter).trigger('chosen:updated');
    }`

I'll see about how to propose a change, I have never really done that before on git