Reputation: 493
How can I set an onchange event to a tag?
I want to transfer the new value to the server without klicking the submit button (therefore in an ajax way)
Upvotes: 0
Views: 766
Reputation: 3047
Grails datepicker tag implemention renders a fixed number of select tags based on the precision that you choose. However, no onchange attribute is added to any of these select tags. The id of each select tag is the id that you specify in the datepicker tag appended by the type of data that each select shows. Eg. the select box for day has id "yourDatepickerTagId_day", the month select tag has id "yourDatepickerTagId_month" etc. To bind the "change" event to any of these select tags you will have to use some custom javascript to handle these events. If you use jQuery, you can use something like this:
$(document).ready(function(){
$("select[id ^= yourDatepickerTagId]").change(function (){
// Do your stuff here...
});
});
Upvotes: 3