Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!