Using alerts on a filtered page
Using alerts on a filtered page
I am using datatables to generate a list of items that has two fields in select boxes. If I change the contents of either box, I fire off an ajax update to a struts 1 action and upon return the client wants an alert box to show the status of the update. All works very well as it is a simple process. However, if I have a longer list and use the search function, the alert that is generated needs to be dismissed multiple times until the original un-filtered page is reached. The page is a jsp.
Here is the code I am using.
$('#rcd').dataTable({
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {"sSwfPath": "swf/copy_csv_xls_pdf.swf"},
"iDisplayLength": 50,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]] ,
"aaSorting": [ [ 1, "asc" ] , [2, "asc"] ],
"bJQueryUI": true,
"bAutoWidth":true,
"sPaginationType": "full_numbers",
"aoColumnDefs" : [ {"bSearchable" : false, "bSortable" : false, "aTargets" : [ 0 ] } ],
"fnDrawCallback" : function(oSettings) {
$('.approvalStatus').on('change' , function(e) {
//console.log("Update Approval Status clicked " + $(this).attr('data-custactid') + " approval status " + $(this).val());
UPDATEAPPROVALSTATUS.update($(this).attr('data-custactid') , $(this).val() );
e.preventDefault();
});
$('.activityStatus').on('change' , function(e) {
//console.log("Update Activity Status clicked " + $(this).attr('data-custactid') + " status " + $(this).val());
UPDATEACTIVITYSTATUS.update($(this).attr('data-custactid') , $(this).val() );
e.preventDefault();
});
}
});
Here is one of the functions that is called:
var UPDATEACTIVITYSTATUS = {
url: "<%=request.getContextPath()%>/editcontactevent.do?method=updateActivityStatusAjax",
update: function(custActId , activityStatus) {
$.ajax({
type: "POST",
url: this.url,
data: {custActivityId: custActId, custActivityStatus: activityStatus},
error: function() {
alert("Activity Status Update failed. Try again.");
return false;
},
success: function() {
alert("Activity Status Update successful!");
return false;
}
});
}
}
If I remove the search entry and use just pagination it works fine with the single level of alert. Any help on getting rid of the additional layers of alert would be appreciated.
Here is the code I am using.
$('#rcd').dataTable({
"sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
"oTableTools": {"sSwfPath": "swf/copy_csv_xls_pdf.swf"},
"iDisplayLength": 50,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]] ,
"aaSorting": [ [ 1, "asc" ] , [2, "asc"] ],
"bJQueryUI": true,
"bAutoWidth":true,
"sPaginationType": "full_numbers",
"aoColumnDefs" : [ {"bSearchable" : false, "bSortable" : false, "aTargets" : [ 0 ] } ],
"fnDrawCallback" : function(oSettings) {
$('.approvalStatus').on('change' , function(e) {
//console.log("Update Approval Status clicked " + $(this).attr('data-custactid') + " approval status " + $(this).val());
UPDATEAPPROVALSTATUS.update($(this).attr('data-custactid') , $(this).val() );
e.preventDefault();
});
$('.activityStatus').on('change' , function(e) {
//console.log("Update Activity Status clicked " + $(this).attr('data-custactid') + " status " + $(this).val());
UPDATEACTIVITYSTATUS.update($(this).attr('data-custactid') , $(this).val() );
e.preventDefault();
});
}
});
Here is one of the functions that is called:
var UPDATEACTIVITYSTATUS = {
url: "<%=request.getContextPath()%>/editcontactevent.do?method=updateActivityStatusAjax",
update: function(custActId , activityStatus) {
$.ajax({
type: "POST",
url: this.url,
data: {custActivityId: custActId, custActivityStatus: activityStatus},
error: function() {
alert("Activity Status Update failed. Try again.");
return false;
},
success: function() {
alert("Activity Status Update successful!");
return false;
}
});
}
}
If I remove the search entry and use just pagination it works fine with the single level of alert. Any help on getting rid of the additional layers of alert would be appreciated.
This discussion has been closed.
Replies