Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda