0

I am having a problem with this function, it simply is now working. I have a module with just a basic form and im using the date module to get the datepicker to pop up and that works fine, but when I select a date from the datepicker the alert is not firing.

this is what i have in my theme js file.

//id for nay_date input field     
$('#edit-nay-date-datepicker-popup-0').datepicker(function() {
              onSelect: function(selectedDate) {
              alert(selectedDate);
            }
        });

and this is the field i have in my module

$form[['nay_date'] = array(
    '#title' => 'Date',
    '#type' => 'date_popup',
    '#description' => '',
    '#required' => TRUE,    
);
2
  • did you wrap your JS in a drupal-friendly version of jQuery's Document ready function ? Does Firebug or Chrome Developer Tools console show any errors ?
    – tenken
    Jul 9, 2013 at 22:36
  • actually yeah i do I get SyntaxError: function statement requires a name onSelect: function(selectedDate) {
    – NukleHead
    Jul 9, 2013 at 22:42

1 Answer 1

1

I use it without a function as the argument like: jsfiddle

//id for nay_date input field     
$('#edit-nay-date-datepicker-popup-0').datepicker({
          onSelect: function(selectedDate) {
          alert(selectedDate);
        }
    });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.