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

133
Views
Complemento JQuery de entrada telefónica internacional: instancia de conjunto de llamadas después de la respuesta html de ajax

Estoy usando este complemento para validar una entrada de tel html https://github.com/jackocnr/intl-tel-input

Envío el formulario a través de una respuesta ajax y recibo la estructura html actualizada. Cuando configuro este html en la página, pierde la instancia del complemento y vuelve a ser una entrada de teléfono normal, sin la instancia del complemento adjunta. ¿Cómo llamo a la instancia anterior a la nueva entrada recibida que técnicamente es la misma?

 // Call and set plugin instance var inputRec = document.querySelector('#phone_number_rec'); var itiRecruiter = window.intlTelInput(inputRec, { hiddenInput: "full", initialCountry: "auto", geoIpLookup: function(callback) { $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) { var countryCode = (resp && resp.country) ? resp.country : "us"; callback(countryCode); }); }, utilsScript : base_url + '/public/assets/modules/intl-tel-input-master/build/js/utils.js', }); // Send form through ajax // Submit recruiter experience $('body').on('submit', '.submit-individual-recruiter', function(e){ e.preventDefault(e); var form = $(this); var post_url = $(this).attr('action'); //get form action url var form_data = $(this).serialize(); //Encode form elements for submission if ($(this)[0].checkValidity() === false) { event.stopPropagation(); form.addClass('was-validated'); } else { $(this).addClass('was-validated'); var responseState = false; var jqxhr = $.ajax({ url : post_url, type: 'post', data : form_data, }).done(function(response){ response = JSON.parse(response); if(response.result == 'success'){ responseState = true; iziToast.success({ message: response.message, position: "topRight" }); } else if(response.result == 'error'){ iziToast.error({ message: response.message, position: "topRight" }); } }); jqxhr.always(function() { if(responseState == true){ var $row = $('#recruiter-experience'); var url = base_url + '/get_info/experience'; $.post( url, function( response ) { response = JSON.parse(response); $row.html(response.recruiterView.data); }); } }); } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

bueno, reemplazó el dom, por lo que el elemento que inicializó el validador de tel desapareció.

una cosa que podría hacer es envolver su inicializador en una función para que pueda llamarlo nuevamente

 function initializeTel() { var inputRec = document.querySelector('#phone_number_rec'); var itiRecruiter = window.intlTelInput(inputRec, { hiddenInput: "full", initialCountry: "auto", geoIpLookup: function(callback) { $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) { var countryCode = (resp && resp.country) ? resp.country : "us"; callback(countryCode); }); }, utilsScript : base_url + '/public/assets/modules/intl-tel-input-master/build/js/utils.js', }); } // call it initially initializeTel(); // and then after u received and parsed the response initializeTel();
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!