I'm using DataTables. I want to let the user select multiple rows and delete them. So far I have it working so it deletes the first row in the selection using the code below.
Ajax Code:
/* Add a click handler for the delete row */
$('#delete').click( function() {
/* fnGetSelected returns an array of integers - each int is a db unique id */
var anSelected = fnGetSelected( oTable );
delete_url = '/delete/' + anSelected[0];
$.ajax({
url: delete_url,
type: 'GET',
});
oTable.fnDeleteRow( anSelected[0] );
fnReloadAjax();
} );
Django Code:
@login_required
def delete(request, row_id):
item = get_object_or_404(Items, pk=row_id, user=request.user)
item.delete()
How could I update this to pass all the row ids to the Django back end? I guess I need to POST the anSelected array, but am not sure how to do this. What Django code would I need to process this integer array?