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

214
Vistas
Ionic 5: How to add event listener to ion-input using Javascript

I am trying to add a event listener to a ion-input so then when there is a change and onkeyup the respective functions execute with the id passed in

Code

<ion-input id="totalTimeOpening" type="text"></ion-input>

<script>
    function testChange(id) {
        console.log(id + " Change");
    }

    function testOnKeyUp(id) {
        console.log(id + " KEYUP");
    }

    document.getElementById("totalTimeOpening").addEventListener('ionChange', testChange.bind('totalTimeOpening'), false);


    document.getElementById("totalTimeOpening").addEventListener('onkeyup', testOnKeyUp.bind('totalTimeOpening'), false);
</script>

The current code seems to pass the whole ion-input object in

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I figured this out.

    function testChange(id) {
        console.log(id + " Change");
    }

    function testOnKeyUp(id) {
        console.log(id + " KEYUP");
    }


        document.getElementById("totalTimeOpening").addEventListener('ionBlur', function(){
            testChange('totalTimeOpening')
        });


        document.getElementById("totalTimeOpening").addEventListener('ionInput', function(){
            testOnKeyUp('totalTimeOpening')
        });

the functions had to go inside function(){here}) and it works. Also the onkeyup won't work with ionic it seems and instead ionInput seems to work as a substitue

about 4 years ago · Juan Pablo Isaza Denunciar
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