0

私はremotefunctionを持つjavascript関数を持っています,,, そのremotefunctionでマップにパラメーターを渡したいです.コントローラーアクションでそのマップ変数を使用したいのですが, ramotefunctionのパラメーターでそれを渡し、それを使用する方法がわかりません.その特定のコントローラーアクションで...

jQuery(document).ready(function(){
 alert("checking for checkbox");
 var countryId = document.getElementById("countryId").value;
    jQuery('#groupdelete').on('click', function(){
        var names = {};
        alert("*********");
        jQuery('input:checked').each(function() {
            alert(jQuery(this).attr("id"));
            if(jQuery(this).attr("id")) {
            var id=jQuery(this).attr("id")
            var costId = "c"+id
            var ntb = document.getElementById(costId).value;
            alert(ntb);
            names[id] = ntb;
            }   
        });
        alert(names[1]);
    })


    ${remoteFunction(action:'addLabServiceToCountry', controller:'country', params:'\'names=\'+names')}

}))

params:'\'names=\'+names' which is not working properly, how to pass map variable in params of remotefunction and in contoller action how to access that.
4

1 に答える 1

0

これを試して:

${remoteFunction({action: "addLabServiceToCountry", controller: "country", params: names});

次に、マップされたすべての名前を取得するremoteFunction()ために反復する必要があります。params

namesまたは、文字列に変換できます。

var namesStr = names.join(',');

次に、文字列を渡します。

${remoteFunction({... , params: namesStr});
于 2013-09-13T11:43:35.260 に答える