following this link:
jQuery 1.9 .live() is not a function
I feel like what I have is right, but it's not executing. I'm upgrading from jQuery 1.5
to 1.9
, I've replaced .live()
with .on()
but my code still isn't executing properly. Is there something that I'm doing wrong?
was:
$('a[rel != "noAJAX"]').live('click', function(event){
Now:
$('a[rel != "noAJAX"]').on('click', 'a', function){
Full code:
$(function(){
// Link handling.
$('a[rel != "noAJAX"]').on('click', 'a', function){
if ($(this).attr('name') != ""){
var currentDiv = $(this).attr('name');
}else{
var currentDiv = divID;
}
$(currentDiv).html(loadingHTML);
$(currentDiv).load($(this).attr('href'));
event.preventDefault();
});
$('form[rel != "noAJAX"]').on('submit', function(event){
if ($(this).attr('name') != ""){
var currentDiv = $(this).attr('name');
}else{
var currentDiv = divID;
}
$(currentDiv).html(loadingHTML);
$.post($(this).attr('action'), $(this).serialize(), function(html){
$(currentDiv).html(html);
});
return false;
});
});