O datepicker do JQuery não funciona após a chamada ajax
eu tenho o seguinte código
<html>
<head>
//included all jquery related stuff ..not shown here
</head>
<body>
<button id = 'btn' />
<div id = 'ct'>
<?php echo file_get_contents('my_ajax_stuff.php'); ?>
</div>
</body>
<script>
$('.datepicker').datepicker({dateFormat: "dd-mm-yy"});
$('#btn').click(function() {
$.ajax({
type: "GET",
url: "my_ajax_stuff.php" ,
success: function(response) {
$('#ct').html(response);
/*added following line to solve this issue ..but not worked*/
//$( ".datepicker" ).datepicker({dateFormat: "dd-mm-yy"});
} ,
error: function () {
$('#ct').html("Some problem fetching data.Please try again");
}
});
});
</script>
</html>
A página
my_ajax_stuff.php
contém um jquery ui datepicker com class = 'datepicker'.No primeiro carregar o datepicker funciona.Mas quando eu clico no botão para recarregá-lo novamente, o conteúdo é substituído por novos conteúdos.Mas o datepicker não está funcionando.Eu tentei inicializando o datepicker dentro do manipulador de sucesso ajax, como você vê.Mas também falhou.Qual é o problema.Como isso pode ser resolvido ??