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

132
Vistas
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 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