Why is DataTables using alerts?
Why is DataTables using alerts?
EaterOfCorpses
Posts: 4Questions: 0Answers: 0
My question is why is DataTables using alerts?
this seems to me:
1. bad practice, if you want to tell the developer something, use console.log
2. if you got corrupt data on a public webpage and a user opens it, the user gets an alert thrown in the face because the data is corrupt, while the user got nothing to do with it, and the user will have a bad experience on that site,
yes, I know I can set the error to 'throw' but this means I need to wrap all my calls to dataTables in try{..}catch's
to me when there happens something wrong it should error silently, console.log what's wrong and go further without breaking other stuff.
so why is DataTables using alerts?
Regards, EaterOfCorpses
this seems to me:
1. bad practice, if you want to tell the developer something, use console.log
2. if you got corrupt data on a public webpage and a user opens it, the user gets an alert thrown in the face because the data is corrupt, while the user got nothing to do with it, and the user will have a bad experience on that site,
yes, I know I can set the error to 'throw' but this means I need to wrap all my calls to dataTables in try{..}catch's
to me when there happens something wrong it should error silently, console.log what's wrong and go further without breaking other stuff.
so why is DataTables using alerts?
Regards, EaterOfCorpses
This discussion has been closed.
Replies
seems to solve the issue but is dirty
You can use `$.fn.dataTableExt.sErrMode = 'throw'` to have it throw errors rather than using alert().
Allan
Can I request:
[code]$.fn.dataTableExt.sErrMode = 'console'[/code]
this should make developing with dataTables much less frustrating :)
I made the code for you already ;)
can you replace
[code]
// line 4711: _fnLog
if ( DataTable.ext.sErrMode == 'alert' )
{
alert( sAlert );
}
else
{
throw new Error(sAlert);
}
return;
[/code]
with:
[code]
switch ( DataTable.ext.sErrMode )
{
case 'alert':
alert( sAlert );
break;
case 'console':
if ( window.console && console.log )
{
console.log( sAlert );
}
break;
default:
throw new Error( sAlert );
}
return;
[/code]
Regards, EaterOfCorpses
Allan
Regards, EaterOfCorpses
Allan