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.

GF Plugin Causes jQuery Conflict

  1. In a Gravity Form customization I made, which is just a mere edit the input fields, it causes a javascript error with tw-sack.js when adding additional fields.

    GF Customization Plugin (sample form included).

    No other plugins are installed. Only GF 1.6.4.4.2 on WP 3.3.x. Any help is greatly appreciated.

    Posted 8 years ago on Wednesday May 30, 2012 | Permalink
  2. i have installed the plugin and imported your sample form, but I don't see any javascript errors. What are the steps I need to take in order to see the error?

    Posted 8 years ago on Wednesday May 30, 2012 | Permalink
  3. Alex, the JS errors are as follows.

    1. Install plugin & activate
    2. Import sample form (get form ID)
    3. Modify plugin (line 32, $wps_gform_id = FORM ID; designed for only one form)
    4. Edit sample form; Add field
    5. Error

    Thanks, Alex!

    Posted 8 years ago on Wednesday May 30, 2012 | Permalink
  4. I don't get the error. Everything seems to be working OK here. If you want to send me a WP admin login and an FTP login to alex@rocketgenius.com I can take a closer look for you

    Posted 8 years ago on Wednesday May 30, 2012 | Permalink
  5. Hello Alex,

    Instead of the jQuery conflict now (on a clean MS install), my 2 customized fields won't save though I see the in $_POST. Am I going to need to hook into gform_pre_submission to make it work?

    Thanks,

    Travis

    Posted 8 years ago on Wednesday May 30, 2012 | Permalink
  6. So I solved this, but there seems to be something wrong with Gravity Forms that I am working around when I customized the input fields.

    I added a JS file via the gform_post_paging hook that went into the hidden fields and added a checked attribute.

    // Adds Checked attribute to hidden fields on page 2 of form
    add_action( 'gform_post_paging', 'wps_gform_add_checked' );
    function wps_gform_add_checked( $form ) {
    
    	// Enqueue script only on the proper form
    	if ( 5 == $form['id'] && ! is_admin() ) {
    		wp_enqueue_script( 'wps_gf_checked', plugins_url( 'js/checked.js', __FILE__ ), array( 'jquery' ), '1.0' ); 
    
    		$args = array(
    			'input_5' => $_POST['input_5'],
    			'input_8' => $_POST['input_8'],
    		);
    		wp_localize_script( 'wps_gf_checked', 'wps_gf_checked', $args );
    	}
    }

    The JS file:

    jQuery(function($) {
    
    	$('#gform_page_5_1 #input_5_5 input').each(function() {
    		if(wps_gf_checked.input_5 == $(this).val())
    			$(this).attr('checked','checked')
    	});
    
    	$('#gform_page_5_1 #input_5_8 input').each(function() {
    		if(wps_gf_checked.input_8 == $(this).val())
    			$(this).attr('checked','checked')
    	});
    
    });

    However, it seems that GF should have stored the $_POST correctly. Because on page 2, here is the $_POST var:

    Array ( [input_5] => design02 [input_8] => background02 [input_1] => [input_6] => [input_2_3] => [input_2_6] => [input_3_1] => [input_3_2] => [input_3_3] => [input_3_4] => [input_3_5] => [input_3_6] => [input_4] => [input_11] => [is_submit_5] => 1 [gform_submit] => 5 [gform_unique_id] => 4fc6b84796a84 [state_5] => {DELETED by wpsmith} = [gform_target_page_number_5] => 2 [gform_source_page_number_5] => 1 [gform_field_values] => )

    So, $_POST obviously sees that input_5 and input_8 are saved correctly, even with the same nomenclature as GF. So I do not understand why GF didn't automatically check these as appropriate. Thoughts?

    Posted 8 years ago on Thursday May 31, 2012 | Permalink