Problem adding events to Datatables DOM
Problem adding events to Datatables DOM
Hi everybody, I've created and populated my datatable using this code:
[code]
function getListaAlbums(){
$.ajax({
data: {
operacion: "listarTodos"
},
type: "POST",
dataType: "JSON",
url: "albumBL.php",
success: function(resp){
listtable.fnClearTable();
$.each(resp,function(i) {
listtable.fnAddData([
resp[i].id,
resp[i].album,
resp[i].artista,
resp[i].annio,
resp[i].calificacion,
"Update"
]);
});
}
});
[/code]
Now I try to add a click event to all my "Update" links generated using this code:
[code]
$("a.updateLink").on("click",function(event){
//My code goes here
});
[/code]
As you can imagine, my event code doesn't work. Does anybody know a solution?
[code]
function getListaAlbums(){
$.ajax({
data: {
operacion: "listarTodos"
},
type: "POST",
dataType: "JSON",
url: "albumBL.php",
success: function(resp){
listtable.fnClearTable();
$.each(resp,function(i) {
listtable.fnAddData([
resp[i].id,
resp[i].album,
resp[i].artista,
resp[i].annio,
resp[i].calificacion,
"Update"
]);
});
}
});
[/code]
Now I try to add a click event to all my "Update" links generated using this code:
[code]
$("a.updateLink").on("click",function(event){
//My code goes here
});
[/code]
As you can imagine, my event code doesn't work. Does anybody know a solution?
This discussion has been closed.
Replies
[code]
$(document).on("click", "a.updateLink", function(event){
//My code goes here
});
[/code]
Allan