NicolasCARPi / jquery_jeditable

jQuery edit in place plugin. Extendable via plugin architecture. Plugins for plugin. Really.
https://jeditable.elabftw.net
MIT License
1.74k stars 459 forks source link

Can't pass valid JSON to Select input? #130

Closed nozpheratu closed 6 years ago

nozpheratu commented 10 years ago

What exactly is a "JSON encoded array" that the select editable type is expecting for the data argument? I have a perfectly valid JSON file in the format specified in the docs, but it doesn't seem to want to accept that if I try to pass it directly, I get the error:

ReferenceError: json is not defined

So I tried to wrap it with JSON.stringify and pass that instead, and now I get this error:

TypeError: context is undefined

If I do a console.log on the returned string, copy and paste that directly as an argument and replace the double quotes at the ends with single quotes it works.

Here's the json in question:

[
    {
        "1": "cheryl",
        "2": "nicolas_badila",
        "3": "hamaha97",
        "4": "talhadad",
        "5": "alhussam1980",
        "6": "johnny",
        "7": "jhaytoring",
        "8": "licensetest2",
        "9": "thedarkship4",
        "10": "mcsack12"
    }
]
zeruitle commented 9 years ago

http://stackoverflow.com/questions/13523729/how-to-json-encode-php-array-but-the-keys-without-quotes

you need use JSON.parse