Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
How to attach event listeners using jQuery QueryBuilder data

I have generated json data from the jQuery Querybuilder which I would like to use to attach event listeners automatically but after trying for several hours, I haven't been able to figure out a way.

Here's the querybuilder json of a html form's elements:

  let json = {
    "condition": "OR",
    "rules": [
      {
        "id": "poll_8002",
        "field": "Question 1",
        "type": "integer",
        "input": "radio",
        "operator": "equal",
        "value": 2
      },
      {
        "id": "poll_8002",
        "field": "Question 1",
        "type": "integer",
        "input": "radio",
        "operator": "equal",
        "value": 4
      }
    ],
    "valid": true,
    "then": [
      {
        "id": "field-poll_8002",
        "type": "single",
        "action": "hide"
      }
    ]
  }

Here's the code that I am trying to generate using the json:

  $('input[name="poll_8002"]').on("click change", function () {
    var val = $(this).val()
    if (val === '2' || val === '4') {
      $('.field-poll_8002').hide()
    } else {
      $('.field-poll_8002').show()
    }
  })

Is there any package/script that can help automate this rather than coding with if/else statements? How can I achieve this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!