fix for _fnJsonString

fix for _fnJsonString

sclvsclv Posts: 1Questions: 0Answers: 0
edited December 2012 in Bug reports
We've been getting a break because we use DataTables on a page that includes some old MooTools and other nonsense that we unfortunately can't remove. MooTools, ingeniously, stomps on the JSON object and creates a new one that does not have a stringify method.

For whatever reason, consistently fixing JSON so it gets stringify back is hard. (a mess of includes, other nonsense).

In any case, the safest/sanest/simplest thing we've found to do ist to patch DataTables itself like so:

[code]var _fnJsonString = (window.JSON) ? JSON.stringify : function( o )[/code]

becomes

[code]var _fnJsonString = (window.JSON && window.JSON.stringify) ? JSON.stringify : function( o )[/code]

It seems like this varient is strictly better and safer.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Fair enough :-). _fnJsonString has been dropped in 1.10 as its no longer needed, but if there is ever a 1.9.5 (I'm not planning on it), I'll put this in.

    Allan
This discussion has been closed.