Correctly Suppressing Warnings in DataTables?

前端 未结 6 2218
小蘑菇
小蘑菇 2020-12-24 12:13

I\'m trying to correctly suppress warnings (alerts) in DataTables. The standard behavior of DataTables is to throw a javascript alert when an error occurs; however, this is

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 12:58

    As of DataTables version 1.10.15, you can set $.fn.dataTableExt.errMode to 'ignore' and it will silently ignore the error messages:

        $(document).ready(function () {
            $.fn.dataTableExt.errMode = 'ignore';
        });
    

    _fnLog DataTables function has the following code :

            if ( type == 'alert' ) {
                alert( msg );
            }
            else if ( type == 'throw' ) {
                throw new Error(msg);
            }
            else if ( typeof type == 'function' ) {
                type( settings, tn, msg );
            }
    

    The default value is 'alert' which is problematic.

    You can also set to 'throw'. It will create javascript error, but will not do disturb the user.

    'ignore' or any other values will just sliently skip the error.

提交回复
热议问题