checkall function does not work well with jquery1.9.1
checkall function does not work well with jquery1.9.1
my codes:
[code]
$(function(){
var oTable = $('#dyntable').dataTable({
"sPaginationType": "full_numbers",
//"bStateSave": true,
"aoColumnDefs": [
{
"bSortable": false,
"bSearchable": false,
"aTargets": [0],
"sClass": "center",
"mRender": function(data, type, full){
return '';
}
},
],
"bProcessing":true,
"bServerSide": true,
"sAjaxSource": "/user/sellerList"
});
/// check all
$('.stdtable').on("click", '.checkall', function(){ // just work once
//$('.stdtable .checkall').live("click", function(){// .live() is deprecated, it work well with jquery1.7.1
$('input', oTable.fnGetNodes()).attr('checked',this.checked);
});
})
[/code]
.live() is deprecated in jquery1.7+ but .on() does not work well.
Is there a good way to solve the version problem?
[code]
$(function(){
var oTable = $('#dyntable').dataTable({
"sPaginationType": "full_numbers",
//"bStateSave": true,
"aoColumnDefs": [
{
"bSortable": false,
"bSearchable": false,
"aTargets": [0],
"sClass": "center",
"mRender": function(data, type, full){
return '';
}
},
],
"bProcessing":true,
"bServerSide": true,
"sAjaxSource": "/user/sellerList"
});
/// check all
$('.stdtable').on("click", '.checkall', function(){ // just work once
//$('.stdtable .checkall').live("click", function(){// .live() is deprecated, it work well with jquery1.7.1
$('input', oTable.fnGetNodes()).attr('checked',this.checked);
});
})
[/code]
.live() is deprecated in jquery1.7+ but .on() does not work well.
Is there a good way to solve the version problem?
This discussion has been closed.
Replies
Allan
It is very strange.When I first click the ".chechall" element it works fine however the second time to failure.
I change the selector to "body" then the result is the same as before.
I use firebug to check the DOM then find that the checkbox is signed 'check="checked"'.It is right but can't be shown on page.Is there a cache?I don't know.
Allan
[code]
$('input', oTable.fnGetNodes()).prop('checked',this.checked);// change .attr() to .prop()
[/code]