Remove multiple row_selected
Remove multiple row_selected
azhararmar
Posts: 6Questions: 0Answers: 0
hi,
i am using ajax to perform some operation like multiple publish/unpublish rows. i am using two datatables the first one contains the datatables with published items and the other one with unpublished items. i am using multiple row select. here is the code i am using for multiple row select.
[code]
//Datatable select muiltiple rows.
var aSelected = [];
$('.dTable tbody tr').live('click', function () {
var id = this.id;
var index = jQuery.inArray(id, aSelected);
if ( index === -1 ) {
aSelected.push( id );
} else {
aSelected.splice( index, 1 );
}
$(this).toggleClass('row_selected');
});
[/code]
and here is my ajax code. what i want is on success function of ajax i want to remove all the selected rows here is my ajax code.
[code]
$.ajax({
type: 'POST',
url: "/admin/item/delete",
data: 'item='+aSelected,
success: function(data) {
item_published.fnDraw();
item_unpublished.fnDraw();
}
});
[/code]
my two datatables initialization code here.
[code]
var item_published = $('#item_published').dataTable();
var item_unpublished = $('#item_published').dataTable();
[/code]
i want to remove all the row_selected class from the tables. in the success: event of ajax. i tried doing several things but nothing work for example
[code]
$("td.row_selected", item_published.fnGetNodes()).removeClass('row_selected');
$(item_published.fnSettings().aoData).each(function(){
$(this.nTr).find("td").removeClass('row_selected');
});
[/code]
nothing is working. what is the correct way of achieving what i want?
Thank you
i am using ajax to perform some operation like multiple publish/unpublish rows. i am using two datatables the first one contains the datatables with published items and the other one with unpublished items. i am using multiple row select. here is the code i am using for multiple row select.
[code]
//Datatable select muiltiple rows.
var aSelected = [];
$('.dTable tbody tr').live('click', function () {
var id = this.id;
var index = jQuery.inArray(id, aSelected);
if ( index === -1 ) {
aSelected.push( id );
} else {
aSelected.splice( index, 1 );
}
$(this).toggleClass('row_selected');
});
[/code]
and here is my ajax code. what i want is on success function of ajax i want to remove all the selected rows here is my ajax code.
[code]
$.ajax({
type: 'POST',
url: "/admin/item/delete",
data: 'item='+aSelected,
success: function(data) {
item_published.fnDraw();
item_unpublished.fnDraw();
}
});
[/code]
my two datatables initialization code here.
[code]
var item_published = $('#item_published').dataTable();
var item_unpublished = $('#item_published').dataTable();
[/code]
i want to remove all the row_selected class from the tables. in the success: event of ajax. i tried doing several things but nothing work for example
[code]
$("td.row_selected", item_published.fnGetNodes()).removeClass('row_selected');
$(item_published.fnSettings().aoData).each(function(){
$(this.nTr).find("td").removeClass('row_selected');
});
[/code]
nothing is working. what is the correct way of achieving what i want?
Thank you
This discussion has been closed.
Replies
[code]
item_published.$("td.row_selected").removeClass('row_selected');
[/code]
Allan