Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda