fnAddData not working with nested data names

fnAddData not working with nested data names

suffixersuffixer Posts: 3Questions: 1Answers: 0

Hi, am I doing something wrong, or is this a bug?

jsfiddle; click item on the master list, should add to "Selected"

1 Works (single nested JSON source):

https://jsfiddle.net/xfxf/nkp1gwp4/
https://catstick.com/jsfiddle/depth1.json

2 Doesn't Work (double nested JSON source):

https://jsfiddle.net/xfxf/700vat5b/
https://catstick.com/jsfiddle/depth1.json

fnAddData does not appear to like nested data names.

Differences with #2:

This question has an accepted answers - jump to answer

Answers

  • suffixersuffixer Posts: 3Questions: 1Answers: 0

    JSON url in #2 should be https://catstick.com/jsfiddle/depth2.json (is correct in the jsfiddle)

  • allanallan Posts: 63,504Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Your JSON file has:

    { "track": {"title": "Title One", "id": 1} }

    But your fnAddData uses:

    { 'track.id': trackId, 'track.title': trackTitle }

    They are not the same. You want to use the same format for both. e.g.:

    { track: { id: trackId, title: trackTitle } }
    

    Allan

  • suffixersuffixer Posts: 3Questions: 1Answers: 0

    Aah, that works perfectly - thanks!

This discussion has been closed.