Salut
Ce referinte /cod JS folosesti pemtru date picker?
Cel mai probabil, cand acel cod se executa la incarcarea paginii, identifica tag-urile <input type="date"> si le face datepicker.
Cel incarcat cu ajax, ne fiind in acel moment in pagina, nu i-se aplica functia de datepicker.
Rezolvarea ar fi ca atunci cand elementul input e adaugat cu ajax in pagina, sa se execute si instructiunea JS care-l face datepicker.
Daca folosesti Webshim datepicker, solutia e sa apelezi functia updatePolyfill() in ajax la elementul unde adaugi input-date, dupa ce este adaugat.
- Sau poti folosi si alte functii, precum: appendPolyfill(), htmlPolyfill().
Detalii si exemple despre configurare gasesti la pagina:
Webshim Demos.
Exemplu cu updatePolyfill()
Cod: Selectaţi tot
Intai sa fie inclus jQuery.<br>
Datepicker 1: <input type="date">
<div id="dtpk2">Datepicker 2: </div>
<button id="btndtpk">Add Datepicker</button>
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js"></script>
<script src="http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js"></script>
<script>
webshims.setOptions('waitReady', false);
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');
//add input-date and make it datepicker
document.getElementById('btndtpk').addEventListener('click', function(){
var resp ='<input type="date" />'; //can be ajax respnse with input-date
$('#dtpk2').append(resp);
$('#dtpk2').updatePolyfill(); //apply polyfill
});
</script>
Demo: