Send custom parameter in x-editable

Abs picture Abs · Oct 15, 2013 · Viewed 11.9k times · Source

I am using x-editable to populate select list in popup. Now I want to send my key to server, my code is something like that

<a href="#" id="status" data-type="select" data-pk="1" data-url="${g.createLink(controller: 'someController', action: 'someAction')}" data-title="Select CV" class="btn btn-primary">
    <image src="${resource(dir: 'images/template', file: 'logo11.png')}"/> ${session.someList?.size()} CV(s) Created
</a>
<script>
    $(function () {
        $('#status').editable({
            value: 1,
            source: [
                <g:each in="${session.someList}" var="xyz"   status="idx">
                    {value: ${xyz?.id}, text: "${xyz.title}",        srsSelected:                    ${xyz.id}, updateXyz: "updateXyz"},
                </g:each>
            ]
        });
    });
</script>

I want to send my srsSelected key to server, I did google but not getting the point...

Edit:

Now I am able to send my key to server(after long research) using

params: function (params) {  //params already contain `name`, `value` and `pk`
    var data = {};
    data['cvSelected'] = params.pk;
    return data;
}

therefore my updated code is:

<a href="#" id="status" data-type="select" data-pk="1" data-url="${g.createLink(controller: 'someController', action: 'someAction')}" data-title="Select CV" class="btn btn-primary">
    <image src="${resource(dir: 'images/template', file: 'logo11.png')}"/>
                ${session.someList?.size()} CV(s) Created
</a>
<script>
    $(function () {
        $('#status').editable({
            value: 1,
            source: [
                <g:each in="${session.someList}" var="xyz"   status="idx">
                    {value: ${xyz?.id}, text: "${xyz.title}", srsSelected:     ${xyz.id}, updateXyz: "updateXyz"},
                </g:each>
            ],
            params: function (params) {  //params already contain `name`, `value` and `pk`
                var data = {};
                data['srsSelected'] = params.pk;
                return data;
            }
        });
    });
</script>

I am able to send value of pk in srsSelected key but this time I need to set value of srsSelected dynamically.

Answer

Abs picture Abs · Nov 7, 2013

And Now I found the method to set the value of srsSelected dynamically as

params: function (params) {
    params.srsSelected = params.pk            
    return params;
} 

and setting the value of data-pk attribute in anchor tag dynamic, we can get srsSelected at controller action.