tmp
tmp

Reputation: 165

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 call controller/action?

Upvotes: 0

Views: 1119

Answers (1)

Dónal
Dónal

Reputation: 187379

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')}"

Upvotes: 2

Related Questions