Grails 单击调用控制器函数

Grails 单击调用控制器函数,grails,gsp,Grails,Gsp,当用户单击复选框时,我想调用一个控制器函数并传递复选框的当前状态,无论它是否选中 我知道如何使用jQuery实现这一点,但我想从复选框本身实现这一点 <g:checkBox id="customer_checkbox" name="customer_checkbox" value="${checked}" /> 复选框将是表单的一部分。使用javascript调用该操作 <g:form name="formName" controller="updateController"

当用户单击复选框时,我想调用一个控制器函数并传递复选框的当前状态,无论它是否选中

我知道如何使用jQuery实现这一点,但我想从复选框本身实现这一点

<g:checkBox id="customer_checkbox" name="customer_checkbox" value="${checked}" />

复选框将是表单的一部分。使用javascript调用该操作

<g:form name="formName" controller="updateController" action="updateIndex">
    <!-- Other form elements -->
    <g:checkBox id="customer_checkbox" name="customer_checkbox" value="${checked}" onChange="document.getElementById('formName').submit();"/>
</g:form>

复选框将是表单的一部分。使用javascript调用该操作

<g:form name="formName" controller="updateController" action="updateIndex">
    <!-- Other form elements -->
    <g:checkBox id="customer_checkbox" name="customer_checkbox" value="${checked}" onChange="document.getElementById('formName').submit();"/>
</g:form>

您需要使用grails taglib中的remoteFunction。此标记为u ajax函数生成:

<select from="[1,2,3,4,5]" onchange="${remoteFunction(action: 'updateIndex', controller:'update',options: '[asynchronous: true]'}" />

有关更多信息,请转到

您需要使用grails taglib中的remoteFunction。此标记为u ajax函数生成:

<select from="[1,2,3,4,5]" onchange="${remoteFunction(action: 'updateIndex', controller:'update',options: '[asynchronous: true]'}" />

有关更多信息,请转到

是否希望在用户单击复选框时刷新页面,即是否需要使用AJAX?是否希望在用户单击复选框时刷新页面,即是否需要使用AJAX?