onLoad function overwritten
onLoad function overwritten
Hey guys, first time poster here, so I'll try to be precise.
I have a table which is being generated server-side. I also, in each row, have a "remove" or "add" link, which removes or adds an element from its group via. ajax.
My problem is this: It works as it should, right up until I use dataTable to search, paginate or sort. Then the ajax functionality I've defined on my links stops working, and the links go back to their JS-disabled behaviour. It's like every time dataTables is refreshed, it overrides the jQuery onload function $(function() { });
I can give example code if you need to see the problem clearer.
I have a table which is being generated server-side. I also, in each row, have a "remove" or "add" link, which removes or adds an element from its group via. ajax.
My problem is this: It works as it should, right up until I use dataTable to search, paginate or sort. Then the ajax functionality I've defined on my links stops working, and the links go back to their JS-disabled behaviour. It's like every time dataTables is refreshed, it overrides the jQuery onload function $(function() { });
I can give example code if you need to see the problem clearer.
This discussion has been closed.
Replies
Before my code was like this:
[code]
$(function(){
$("#quotes_table").dataTable({
"sPaginationType": "full_numbers"
});
$(".plus").click(function(e){
var plus = $(this);
$.ajax({
url: this.href,
type: 'post',
dataType: 'script',
data: { '_method': 'create' },
success: function(){
plus.html(' ');
}
});
return false;
});
$(".minus").click(function(e){
var minus = $(this)
$.ajax({
url: this.href,
type: 'post',
dataType: 'script',
data: { '_method': 'delete' },
success: function(){
minus.html(' ');
}
});
return false;
});
});
[/code]
But moving [code]
$("#quotes_table").dataTable({
"sPaginationType": "full_numbers"
});[/code]
to the end of the onLoad function solves the problem.
Can anyone explain this to me?
Allan
Allan