Advertisement
chrishajer

Force datepicker to be open on page load

Feb 22nd, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2. // this code goes in your theme's functions.php file
  3. // http://www.gravityhelp.com/forums/topic/display-the-calendar-in-the-opened-state#post-150402
  4. // only enqueue the script when form 328 is being embedded
  5. // change 328 here to your form's ID
  6. add_action('gform_enqueue_scripts_328', 'enqueue_open_datepicker', 10, 2);
  7. function enqueue_open_datepicker($form, $is_ajax) {
  8.     // enqueue the script to open the datepicker.  Script is stored in the child theme /js/ subdirectory,
  9.     // and depends on jQuery and the jQuery UI Datepicker script
  10.     wp_enqueue_script('open_datepicker', get_stylesheet_directory_uri() . '/js/datepicker-open.js', array('jquery','jquery-ui-datepicker'));
  11. }
  12.  
  13. // this code goes in to a file called datepicker-open.js in a folder inside your theme folder, called js
  14. // this will force all datepicker open on load.  You can use different selectors here if you want to
  15. // instead of .gform_wrapper and input
  16. jQuery(document).ready(function($) {
  17.     $( "body .gform_wrapper input.datepicker" ).datepicker( "show" );
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement