Q:

Rails & jQuery Datepicker - Save form when date is selected

I would like to automatically save a form when the user selects a date (or makes any change for that matter, whether it be date or time) from the datepicker popup.  In rails I'm using a form with :remote => true to simply change a due date attribute.  It's just one field, so it feels like overkill to make users click a 'submit' button after picking a date.  I currently have it set up to display the updated date using AJAX once the user updates the form, but again, I'd like this done w/o actually clicking a submit button. 
Here's my erb:
<%= form_for todo, :remote => true, :url => update_todo_project_path, :html => {:id => "todo#{todo.id}" } do |f| %>
   <%= f.hidden_field :id %>
   <%= f.text_field :due %>
   <%= f.submit %>
<% end %>

Javascript (just an external js file):
$('input#project_todo_due').datetimepicker({
    dateFormat: 'yy-mm-dd',
    timeFormat: 'hh:mm'
});

And update_todo.js.erb:
$("#dueon<%= @todo.id%>").html("<%= raw escape_javascript(render(:partial => 'duedate')) %>");

A:

I'm going to take a stab at it:
$('input#project_todo_due').datetimepicker({
  dateFormat: 'yy-mm-dd',
  timeFormat: 'hh:mm',
  onClose: function(strDate, datepicker) {
    // According to the docs this situation occurs when 
    // the dialog closes without the user making a selection
    if(strDate == "") {
      return;
    }

    // According to the docs this refers to the input
    // Some digging in jquery-ujs on github make it
    // look like triggering the 'submit.rails' event
    // on the form will cause the normal unobtrusive
    // js helpers to post the form. 
    // What's not clear is if the input element has the
    // updated value at this point. 
    $(this).parent().trigger('submit.rails')
  }
});

The docs I used:
jQuery UI Datepicker -- onClose
jquery-ujs on Github -- relevant lines begin at 362

