Question

I am populating checklist using remote source. My problem is that the remote source returns {count: n, results: {...}}, and x-editable doesnt expect to have to look in response.results to get the list.

I have tried the following, which does not solve:

       $ages.editable({
            type: 'checklist',
            source: '/api/ages/',
            sourceOptions: {
                success: function(resp){
                    return resp.results;
                }
            }
        })

Using console, I can see that .success is being hit, but the behaviour on screen is the "loading" spinner keeps on spinning.

Was it helpful?

Solution

$.ajax has dataFilter callback, which passes return value to success. Note dataFilter must return JSON, so below works:

dataFilter: function(resp){
    return JSON.stringify(JSON.parse(resp).results);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top