vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.72k forks source link

Documentation Missing Params Example #1059

Open obinoob opened 6 years ago

obinoob commented 6 years ago

Hi,

First of thank you so much for such a great library.

I had a lot of troubles finding a solution to send a CRSF token along with data. This is my solution and I'm sure that other users would appreciate an example exposing on how to do it. Not saying that it is difficult but it is missing in documentation. Perhaps you could improve this code, hope you can include it.

Thank you again,

$('.editable-filter').editable({
    type: 'text',
    url: '/controller/action/',
    title: 'New Value: ',
    params: function (params) {
        return {
            'pk': params.pk,
            'value': params.value,
            'name': params.name,
            '_csrfToken': $.cookie('_csrfToken')
        }
    },
    ajaxOptions: {
        type: 'post',
        dataType: 'json'
    }
});