How to get date from calendar:datePicker and make an ajax call?
I've added plugin calendar http://www.grails.org/plugin/calendar to my web app. I don't know how to handle change value event, get date and call ajax request to refresh some other part of the page that depends on this date. Where should I ca开发者_Python百科ll controller/action?
Attach an onchange
listener to the element(s) that the calendar plugin stores the date/time in. You can use the remoteFunction tag to generate the JavaScript function that makes the AJAX call. For example, if the time is stored in an element with id foo
, the following will invoke the myAction
action of FooController
with the selected date sent as the value of the currentDate
parameter
$('#foo').onchange = "${remoteFunction(action:'myaction', controller: 'bar'
params:'\'currentDate=\' + this.value')}"
精彩评论