Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x-editable process response of remote source

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.

like image 510
Django Doctor Avatar asked Jan 01 '26 00:01

Django Doctor


1 Answers

$.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);
}
like image 65
Django Doctor Avatar answered Jan 03 '26 16:01

Django Doctor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!