Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG?] issues with 'change.querybuilder' event #556

Closed
WilliamStam opened this issue Aug 17, 2017 · 11 comments
Closed

[BUG?] issues with 'change.querybuilder' event #556

WilliamStam opened this issue Aug 17, 2017 · 11 comments

Comments

@WilliamStam
Copy link

WilliamStam commented Aug 17, 2017

https://jsfiddle.net/42t6chv6/2/

add rules etc to see the event fired. as soon as you click [x delete] on any rule or group - it doesnt fire the change event.

is this a bug?

i tried adding the 'afterDeleteRule.queryBuilder' to it aswell, but it doesnt fire the event either
.on("change.queryBuilder afterDeleteRule.queryBuilder", function() {


changing the operator fires the change.queryBuilder event twice.

@WilliamStam WilliamStam changed the title [BUG?] removing a rule doesnt fire the 'change.querybuilder' event [BUG?] issues with 'change.querybuilder' event Aug 17, 2017
@mistic100
Copy link
Owner

mistic100 commented Aug 17, 2017

"change.queryBuilder" does not exist yet #498

I tried your fiddle with "afterDeleteRule.queryBuilder" and it works very well

@WilliamStam
Copy link
Author

sorry was editing the comment. so things might get wonky with this....

if the event doesnt exist yet then what event is being fired to output "changed" in the log area?

https://jsfiddle.net/42t6chv6/3/

#confused

@WilliamStam
Copy link
Author

WilliamStam commented Aug 17, 2017

latest fiddle https://jsfiddle.net/42t6chv6/5/ afterDeleteRule.queryBuilder now seems to work, it didnt earlier - i think, was battling with it for about an hour - :/ some days code can be really infuriating.

still no idea where change.queryBuilder comes from if its not added yet. and the operator select fires "it" twice

edit found it..: https://github.com/mistic100/jQuery-QueryBuilder/blob/dev/src/core.js line 200 odd.

// group condition change
    this.$el.on('change.queryBuilder', Selectors.group_condition, function() {
        if ($(this).is(':checked')) {
            var $group = $(this).closest(Selectors.group_container);
            self.getModel($group).condition = $(this).val();
        }
    });

    // rule filter change
    this.$el.on('change.queryBuilder', Selectors.rule_filter, function() {
        var $rule = $(this).closest(Selectors.rule_container);
        self.getModel($rule).filter = self.getFilterById($(this).val());
    });

    // rule operator change
    this.$el.on('change.queryBuilder', Selectors.rule_operator, function() {
        var $rule = $(this).closest(Selectors.rule_container);
        self.getModel($rule).operator = self.getOperatorByType($(this).val());
    });

so probably still a WIP i guess

@mistic100
Copy link
Owner

No it's not a WIP.

This event is just the input/select events bubbling up in the DOM, it is not triggered by the builder but by the browser.

@WilliamStam
Copy link
Author

WilliamStam commented Aug 17, 2017

so best way to do a "change" would be something like

.on("afterAddRule.queryBuilder afterAddGroup.queryBuilder afterApplyGroupFlags.queryBuilder afterApplyRuleFlags.queryBuilder afterClear.queryBuilder afterCreateRuleFilters.queryBuilder afterCreateRuleInput.queryBuilder afterCreateRuleOperators.queryBuilder  afterDeleteGroup.queryBuilder afterDeleteRule.queryBuilder afterInit.queryBuilder afterReset.queryBuilder afterSetRules.queryBuilder afterUpdateGroupCondition.queryBuilder afterUpdateRuleFilter.queryBuilder afterUpdateRuleOperator.queryBuilder afterUpdateRuleValue.queryBuilder", function(event) {

(i just took all the api "after" events)

also using a debounce script to only fire once


heres an events fiddle for anyone else thats interested with the "after" events

https://jsfiddle.net/42t6chv6/6/

@WilliamStam
Copy link
Author

so reason for all my "issues" this is what im using queryBuilder for. basically to build the where string for "dummies". working great! (thank you for your patience, help and most of all for having developed this awesome plugin!)

image

@mistic100
Copy link
Owner

nice, always a pleasure to know how it is integrated.

@nikataus
Copy link

So what William suggests can be used until global "change" event has been implemented in 2.4.5 release?

@mistic100
Copy link
Owner

of course, this is only existing events

@nikataus
Copy link

Thanks, just confirming :),

@vmitchell
Copy link

Hey Damien,
I think there is no 'change' event fired when deleting a rule. There is a separate event for deleting a rule of course, but still 🔨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants