Reputation: 1858
I'm new to grails and not quiet understanding why my form keeps calling the index method of my controller even though I assign the action to call a test method.
Here is the gsp:
<g:form action="test">
<g:submitToRemote update="updateMe" value="Click Me!" />
</g:form>
<div id="updateMe"></div>
Here is how it is rendered:
<form action="/CEFConnect/CEFTicker/test" method="post">
<input onclick="jQuery.ajax({type:'POST',data:jQuery(this).parents('form:first').serialize(),
url:'/CEFConnect/CEFTicker/index',
success:function(data,textStatus){jQuery('#updateMe').html(data);},
error:function(XMLHttpRequest,textStatus,errorThrown){}});
return false"
type="button" value="Click Me!">
</form><div id="updateMe"></div>
The ajax is calling '/CEFConnect/CEFTicker/index'
and not '/CEFConnect/CEFTicker/test'
Here is the controller:
class CEFTickerController {
def index() {
render "<p>index called.</p>"
}
def list() {
}
def test() {
render "<p>test called.</p>"
}}
The page I'm calling this from is '/CEFConnect/CEFTicker/list'. So, I'm not calling the action from the current action.
Upvotes: 0
Views: 1013
Reputation: 50285
Use url
in submitToRemote
<g:submitToRemote url="[action: 'test']" update="updateMe" value="Click Me!"/>
Per documentation.
Upvotes: 4