A repost of http://datatables.net/forums/discussion/comment/38391 from DataTables.

Possible bug: IE8 won’t show table: “‘aTargets’ is null or not an object”

I’ve got a datatable that works in Opera/FF/Chrome, but not in IE8. I’m running 1.9.3.

In IE8, it shows this error:

>     Webpage error details
> 
>     User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.4506.2152)
>     Timestamp: Tue, 21 Aug 2012 20:16:07 UTC
> 
>     Message: 'aTargets' is null or not an object
>     Line: 19
>     Char: 4817
>     Code: 0
>     URI: http://MYDOMAIN/assets/application-3b0e185edc6cf38f7bdac3207f7b8585.js
>     

In the min.js code, it corresponds to this bit:

>     function ua(e,t,n,r){var s,u,a,f,l;if(t)for(s=t.length-1;0<=s;s--){var c=t[s].aTargets;i.isArray(c)||E(e,1,"aTargets must be an array of targets, not a "+typeof c),u=0;"
>     

which I believe corresponds to line 385 in the current d62ac0 release.

I’ve defined my columns with “aoColumnDefs”, and each column has an “aTargets” defined for it.

Is this something anyone has run into before? I’m assuming that Datatables should be supporting IE8.

The debugger output is here:
http://debug.datatables.net/acabak

And here’s my full aoColumnDefs, because if it’s my fault, I’m guessing it would be in here:

>     $("#trades_tbl").dataTable({
>         "sAjaxSource" : "/trades/search.datatables",
>     //    "aaSorting" : [[0,'asc']], // sorting on initialization
>         "bServerSide"  : true,
>         "fnServerData" : simpleDatatables,
>         "bFilter" : false,
> 
>         "sDom" : "lfriptip",
> 
>         // pagination
>         "aLengthMenu" : [10,50,100,500,1000],
>         "bPaginate" : true,
>         "bLengthChange" : true, // lets user choose number of records from menu
>         "sPaginationType" : "input",
> 
>         "aoColumnDefs": [
>           { "aTargets": ["id"], "bVisible":false },
>           { "aTargets": ["tddt"], "sName":"tddt" },
>           { "aTargets": ["bors"], "sName":"bors" },
>           { "aTargets": ["quanty"], "sName":"quanty" },
>           { "aTargets": ["exch"], "sName":"exch" },
>           { "aTargets": ["fcondt"], "sName":"fcondt" },
>           { "aTargets": ["desc"], "sName":"desc" },
>           { "aTargets": ["porc"], "sName":"porc" },
>           { "aTargets": ["trntp"], "sName":"trntp" },
>           { "aTargets": ["fprice"], "sName":"fprice" },
>           { "aTargets": ["cmns"], "sName":"cmns" },
>           { "aTargets": ["strik"], "sName":"strik" },
>           { "aTargets": ["excf"], "sName":"excf" },
>           { "aTargets": ["exsf"], "sName":"exsf" },
>           { "aTargets": ["nfa"], "sName":"nfa" },
>           { "aTargets": ["altcur"], "sName":"altcur" },
>           { "aTargets": ["regcod"], "sName":"regcod" },
>           { "aTargets": ["acctno"], "sName":"acctno" },
>           { "aTargets": ["trncde"], "sName":"trncde" },
>           { "aTargets": ["price"], "sName":"price" },
>           { "aTargets": ["nitd"], "sName":"nitd" },
>           { "aTargets": ["pandl"], "sName":"pandl" },
>           { "aTargets": ["cnyear"], "sName":"cnyear" },
>           { "aTargets": ["month"], "sName":"month" },
>           { "aTargets": ["fprmpt"], "sName":"fprmpt" },
>           { "aTargets": ["futcod"], "sName":"futcod" },
>           { "aTargets": ["foro"], "sName":"foro" },
>           { "aTargets": ["slspsn"], "sName":"slspsn" },
>           { "aTargets": ["crncod"], "sName":"crncod" },
>           { "aTargets": ["stlpr"], "sName":"stlpr" },
>           { "aTargets": ["txty"], "sName":"txty" },
>           { "aTargets": ["txcd"], "sName":"txcd" },
>           { "aTargets": ["brokr"], "sName":"brokr" },
>           { "aTargets": ["txno"], "sName":"txno" },
>           { "aTargets": ["cmsty"], "sName":"cmsty" },
>           { "aTargets": ["futmcd"], "sName":"futmcd" },
>           { "aTargets": ["orgzcd"], "sName":"orgzcd" },
>           { "aTargets": ["feerec"], "sName":"feerec" },
>           { "aTargets": ["fbkr"], "sName":"fbkr" },
>           { "aTargets": ["feeamt"], "sName":"feeamt" },
>           { "aTargets": ["feectc"], "sName":"feectc" },
>           { "aTargets": ["feehf"], "sName":"feehf" },
>           { "aTargets": ["sdbk"], "sName":"sdbk" },
>           { "aTargets": ["edit","destroy"], "bSortable":false, "bSearchable":false },
>           { "aTargets": ["edit"], "sDefaultContent":"",
>             "fnRender" :function(o) {
>               return '<a href="/trades/' + o.aData[0] + '/edit" id="editTrade' + o.aData[0] + '">Edit</a>'
>             },
>           },
>           { "aTargets": ["destroy"], "sDefaultContent":"",
>             "fnRender" :function(o) {
>               return '<a href="/trades/' + o.aData[0] + '" data-confirm="Are you sure?" data-method="delete" id="destroyTrade' + o.aData[0] + '" rel="nofollow">Destroy</a>'
>             },
>           },
>         ],
>       });
>     

you’ve got trailing commas at the end of the aoColumnDefs array and the init object. IE does not behave the same way as other browsers with the trailing comma - here is it inserted an undefined element at the end of the array, while older IE versions will throw an error.

Argh! Thanks, Allan, you nailed it!

This discussion has been closed.


Source