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

309
Vistas
Using intl-tel-input and vuejs2 together

I am trying to implement https://github.com/jackocnr/intl-tel-input with vuejs2.

If I add inside one jQuerydocument.ready, $('#phone').intlTelInput({ options...})

Everything works as expected but when I'm trying to fetch the value of the input field and some boolean valid property, I am always checking the value one step behind.

My checking method looks like:

    validatePhoneNumber: function() {
        var validPhoneNo = $("#phone").intlTelInput("isValidNumber");
        var phoneNo = $("#phone").intlTelInput("getNumber");
        console.log(phoneNo + ' -> ' + validPhoneNo); //this line returns values one step behind
        bus.$emit('validate-phone', validPhoneNo)
    }

The HTML:

<input class="form-control" @keydown="validatePhoneNumber" :class="{validInput: validPhone }" type="text" name="phone" value="" id="phone" :phone_number="phone_number">

I believe the solution would be to create a new directive for this matter, and I tried the following:

Removed the part where I instantiated the intlTelInput on document.ready and made this instead:

Vue.directive('telinput', {
    bind: function(el) {
        $(el).intlTelInput({
            //options here...
    }
});

and added v-telinput to my HTML code above.

with this, nothing seems to work.

What am I missing there?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try to use @keyup instead of @keydown

about 4 years ago · Santiago Trujillo 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