again. Well,I'm doing also pushState script i was doing it with jquery 1.6.2 but it was working with .live() but with v2.0.3 of jquery it's deprecated. So, I don't know how can I replace it, look:
$('.a').live('click', function(e){
history.pushState(null, null, this.href);
replacePag(this.href);
e.preventDefault();
$(window).bind('popstate', function(){
replacePag(location.pathname);
});
});
When i run it with one element with class .a it works fine, but my page has many .a elements. I tried it with .on() but neither it doesn't works.
$('.a').on('click', function(e){
history.pushState(null, null, this.href);
replacePag(this.href);
e.preventDefault();
$(window).bind('popstate', function(){
replacePag(location.pathname);
});
});
If you can help me, Thanks for your help.
Well, my script is:
$(function(){
var replacePag = function(ur) {
$.ajax({
url: ur,
type: 'get',
dataType: 'html',
success: function(dat){
var domm = $(dat);
var titl = domm.filter('title').text();
var htm = domm.filter('#body').html();
$("#body").fadeOut(100,
function(){
$(this).html(htm);
$('title').text(titl);
}).fadeIn( 1000 );
}
});
}
$('.a').live('click', function(e){
history.pushState(null, null, this.href);
replacePag(this.href);
e.preventDefault();
$(window).bind('popstate', function(){
replacePag(location.pathname);
});
});
});