我正在使用grails 2.1.1。我有一个远程函数,我想通过g:remoteFunction传递多个Java脚本变量。但是没有js变量要传递给 Controller ​​。我的js变量带有下划线,无法识别。谁能帮我这个忙吗?!!!这是我在下面的尝试:

我的功能>>>

function addNewBill(){ 
    var orgId = $('#aaOrgIdAaOrg').val(); 
    var ccId = $('#costCenter').val(); 
    if(orgId != null && orgId != "null" && orgId != "" && ccId != null && ccId != "null" && ccId != ""){ 
        $('#ccModal').modal('hide'); 
        ${remoteFunction(action: 'createBill', params: [purchaseOrderId: purPoMstInstance.id, aaOrgIdAaOrg: orgId, costCenter: ccId], update: 'bill')}             
    } 
} 

请您参考如下方法:

当remoteFunction最终呈现jQuery函数时,您可以使用params选项,使用jQuery选择器或所需的Js vars或函数来包含变量。

这是一个例子。如您所见,params值只是一个字符串,但是在渲染器之后,它将被运行,因为那是js;)

<button type="button" onclick="${remoteFunction(controller: 'category', action: 'save', update: "eventsDiv", 
   params: '\'type=\' + myJSvar)}"> 
         ${message(code: 'default.button.save.label')} 
</button> 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!