mistic100 / mistic100/jQuery-QueryBuilder

Rule properties missing in event hooks (Exception: TypeError: Cannot read property 'data' of undefined at Rule.get [as data]....)

Open
#829 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
544
PR merge metrics
No merged PRs in 30d

Description

I enjoy the way this plug-in works, in fact I am trying to implement on top of it. From the documentation I understand that the room I have to implement custom features is mostly in event hooks, however, the parameters provided in these hooks are incomplete.

For example, I cannot access a rule's data or error from the Rule object provided in the getRuleFilters callback (or in any other as far as I know...). Instead, I only get the rule's reference with no properties initialized other than its id and $el.

$('#builder').on('getRuleFilters.queryBuilder.filter', (filters, rule) => {
    // Shows all the properties of `Rule` after it's been initialized
    console.log(rule);
    // But actually, properties such as `data`, `error`, `filter`, `flags` are all undefined
    console.log(_.cloneDeep(rule));
});
Schermata 2019-10-11 alle 12 22 56

TL;DR: How do I get the full Rule object in event hooks?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the getRuleFilters.query-builder.filter event and the Rule object supplied to its callback. Compare the initialized Rule shown in the issue with the object exposed in the hook, focusing on data, error, filter, and flags. Done means event hooks provide the full Rule properties rather than only id and $el, without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.