jQuery Datepicker : How to add option which accepts a function as an argument


I have added a date_popup field to a form :

                $form['arrival_date'] = array(
                  '#type' => 'date_popup',
                  '#title' => t('Arrival date'),
                  '#date_format' => 'd/m/Y',
                  '#date_year_range' => '0:+1',
                  '#date_label_position' => 'none',
                  '#default_value' => '',
                  '#size' => '10',

I want to add an option to run a function using the onClose option so my js is :

(function ($){

  Drupal.behaviors.ios2 = {
    attach: function (context, settings) {
            onClose: function (date) {
              //date will have the new date or empty string if no date has been selected
              // Do something



However the onClose event never executes. If I remove the ‘option’ argument thus :


it does work, but my suspicion is that it is replacing the datepicker with a new one, rather than altering the existing options.

قالب وردپرس