最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Send custom parameter in x-editable - Stack Overflow

programmeradmin5浏览0评论

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.

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.

Share Improve this question edited May 23, 2014 at 22:12 BenMorel 36.6k51 gold badges205 silver badges335 bronze badges asked Oct 15, 2013 at 5:24 ABCABC 4,37310 gold badges47 silver badges78 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 13

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.

发布评论

评论列表(0)

  1. 暂无评论