PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

[bug] Including with template function causes jquery ui to fail

  1. I don't even know how to explain this... but what I realized is that if I include the form in the template using:

    <?php gravity_form(2, false, false); ?>

    it will fail to load the jquery ui accordion that wraps it

    fwiw, I use:

    wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css"); to style it and include the javascripts the same way:

    wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
    
    wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
    
    wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);

    but in either case it (with or without those includes) it fails.

    However, if I include via shortcode:

    [gravityform id=2 name=Contact title=false description=false]

    everything is hunky dory.

    Posted 13 years ago on Wednesday November 17, 2010 | Permalink
  2. What accordion script are you referring to? Gravity Forms doesn't use an accordion script.

    When including Gravity Forms via the function call you must enqueue all necessary JS and CSS manually. This isn't a bug, it's intended functionality. The function call can be used anywhere and at anytime on a WordPress site and enqueue only works at certain points in the WordPress processing so the function call can't do it automatically.

    Posted 13 years ago on Wednesday November 17, 2010 | Permalink
  3. I'm using jquery.ui.accordion from the 1.8.6 package.

    wp_enqueue_style('jquery-ui', get_bloginfo('template_url') . '/css/redmond/jquery-ui-1.8.5.custom.css');
    wp_enqueue_style('ui-selectmenu', get_bloginfo('template_url') . '/css/ui.selectmenu.css');
    wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css");
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('ui-widget', get_bloginfo('template_url') . '/js/ui.widget.js', array('jquery-ui-core'));
    wp_enqueue_script('ui-accordion', get_bloginfo('template_url') . '/js/ui.accordion.js', array('jquery-ui-core', 'ui-widget'));
    wp_enqueue_script('ui-selectmenu', get_bloginfo('template_url') . '/js/ui.selectmenu.js', array('jquery-ui-core'));
    wp_enqueue_script('page-partners', get_bloginfo('template_url') . '/js/page.partners.js',array('jquery-ui-core'),'1.0',true);
    wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
    wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
    wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);

    am I missing any enqueues?

    Posted 13 years ago on Wednesday November 17, 2010 | Permalink
  4. okay, I've added the following but I don't know what the "proper" dependencies should be. I just defaulted to the datepicker.

    wp_enqueue_script("gforms_json", WP_PLUGIN_URL . "/gravityforms/js/jquery.json-2.2.js", array("gforms_ui_datepicker"), "1.3.9", true);
    wp_enqueue_script("gforms_multipage", WP_PLUGIN_URL . "/gravityforms/js/multipage.js", array("gforms_ui_datepicker"), "1.3.9", true);
    wp_enqueue_script("gforms_textareacount", WP_PLUGIN_URL . "/gravityforms/js/jquery.textareaCounter.plugin.js", array("gforms_ui_datepicker"), "1.3.9", true);

    ah... but here's a bummer, the paging closes the accordion on "next"

    edit: I had to edit ajax:

    <?php gravity_form(2, false, false, false, null, true); ?>

    Posted 13 years ago on Wednesday November 17, 2010 | Permalink
  5. you can mark this as resolved

    Posted 13 years ago on Wednesday November 17, 2010 | Permalink