Ajax and append html: selector not work
Hi at all.
I have a trouble.
I have this code:
-
<div class="calendar">
<table>
<tr>
<th><a href="?nov">[<<]</a></th>
<th >dicembre</th>
<th><a href="?gen">[>>]</a></th>
</tr>
....
....
</table>
</div>
Is a Calendar.
When i click onto a link, the page was reloaded.
I need that the page was static.
So i use Ajax.
But when i append a new code, the selector change and not work more.
This is my JS code:
-
<script type="text/javascript">
//<![CDATA[
$(function() {
var navigation=$(".calendar tr:first a");
navigation.click(function(){
var content_url=$(this).attr("href");
$.ajax({
method: "get",url: content_url+"&ajax=attivo",
data:"form=ajax",
//mostra il loading qundo clicco
beforeSend: function(){},
//nascondi il loading al caricamento
complete: function(){},
//visualizza l'html se esiste un valore di ritorno
success: function(html){
//inserisci l'html
$(".calendar").html(html);
****
}
//chiudi ajax()
});
//chiudi click()
return false;
});
});
//]]>
</script>
I have tried to intert a new declaration of variable
navigation where i have inser 4 *. But not work yet.
Have you an idea to help me?
Thank.