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

225
Visualizações
Odoo 14 Change value of input in Javascript

I am calling an api from python that returns json to the javascript function. When returning the data I am setting the value of an input field using jquery. But when saving theform the field value is not being saved. What's the solution? Thanks in advance.

$.each(data['payload'], function(key, val) {
    let el = $('[name='+key+']');
    el.val(val);
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Sometimes websites use form fields only as "frontend" for some internal state that gets synced whenever the data in the field changes.

When a user changes the contents of the field, a change event is fired. This won't happen if you programmatically change the value though, so such a change would not be picked up by code listening for changes.

To fix this problem, you can manually trigger a change event on the field after modifying its value. You seem to be using jQuery, there you can simply use the change() method like this:

el.val(val).change()
           ^^^^^^^^^
about 4 years ago · Juan Pablo Isaza Relatório
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