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

183
Visualizações
Submit button not get re-enabled

I have a Rails form, to which I have attached a submit handler which has a try / catch block and in the catch block, I display error message to the user and try to re-enable the submit button.

The button for some reason does not get re-enabled.

If I execute the same code in browser console later, the button gets re-enabled.

below is the relevant part of the code


function displayError(action,err){
  jQuery('input[name=commit]').removeAttr('disabled');
};

form.addEventListener('submit', (event) => {
try {

} catch(e) {
displayError('submit', e);
}
});

Any help on this will be really great, Thanks.

*** Update 1


if i console.log(jQuery('input[name=commit]')); I see this

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

YOu can use JQuery to enable and disable buttons in a UI. Assume the id of the button is

id="singlebutton"

Using JQuery, you can disable this button via this code:

$('#singlebutton').prop("disabled", true);

This disables the button.

enter image description here

Likewise to enable it, use:

  $('#singlebutton').prop("disabled", false);
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