fix for _fnJsonString
fix for _fnJsonString
sclv
Posts: 1Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
Allan