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

126
Visualizações
jquery-modal keeps last input

I want to use the jquery-modal plugin to make comments for several form elements. Its working fine, as long there is no keyboard input. Otherwise it remembers the last input and keeps that in the textarea, even if I empty it before.

This is the form that is shown in the modal window.

<a title="" href="#" onclick="getRechKomm('12345'); return false;" class="edit_komm">Kommentar</a>

<form id="RechKommForm" class="none">
    <h3></h3>
    <p><textarea name="kommentar" id="ptrRechKomm"></textarea></p>
    <p><input type="hidden" name="rechid" id="ptrRechKommID" value=""></p>
</form>

<script>
    function getRechKomm(rechnr){
        $('#ptrRechKomm').html('');
        $.ajax({
            type: "POST",
            url: "ptr_getrechkomm.php",
            data: {rechnr: rechnr},
            success: function(data){
                readSession();
                $('#ptrRechKomm').html(data);
                $('#ptrRechKommID').val(rechnr);
                $('#RechKommForm').modal({
                    escapeClose:false,
                    clickClose: false,
                    fadeDuration:500
                });
            }
        });
    }
    $('#RechKommForm').on($.modal.BEFORE_CLOSE, function(event, modal) {
        $.ajax({
            type: 'POST',
            url: 'ptr_putrechkomm.php',
            cache: false,
            data: $("#RechKommForm").serialize(),
            success: function (data) {
                $('#ptrRechKomm').html('');
                $('#ptrRechKommID').val('');
            }
        });
    });
</script>

So if call the comment for the ID 12345 and write a comment "Komm 12345", everything is fine. After that I call the comment for ID 23456, that may be already "Komm 23456". It is loaded from the database and put into the textarea #ptrRechKomm, but the first text is still there. So in the textarea is "Komm 12345Komm 23456".

Where is the old content coming from and how to delete it?

Update: Forget that all! Don't know why, but I thought that a textarea has to be filled by html(). Thats working, but only once. Filling it by val() is the correct way!

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