Conversation
supportThe plugin did exactly what I needed it to do on the first page of the form, but did not work on additional pages. It was a simple fix, please build it into a future release: function gfap_script() { ?> <script> function vf_add_gf_placeholders() { // Convert label to placeholder <?php $gfap_class_pc = get_option(‘gfap_class’); if ($gfap_class_pc) { $gfap_class = ‘gfap_placeholder’; } else { $gfap_class = ‘gform_wrapper’; } ?> jQuery.each(jQuery(‘.<?php echo $gfap_class; ?> input, .<?php echo $gfap_class; ?> textarea’), function () { var gfapId = this.id; var gfapLabel = jQuery(‘label[for=’ + gfapId + ‘]’); jQuery(gfapLabel).hide(); var gfapLabelValue = jQuery(gfapLabel).text(); jQuery(this).attr(‘placeholder’,gfapLabelValue); }); // Use modernizr to add placeholders for IE if(!Modernizr.input.placeholder){jQuery(“input,textarea”).each(function(){if(jQuery(this).val()==”” && jQuery(this).attr(“placeholder”)!=””){jQuery(this).val(jQuery(this).attr(“placeholder”));jQuery(this).focus(function(){if(jQuery(this).val()==jQuery(this).attr(“placeholder”)) jQuery(this).val(“”);});jQuery(this).blur(function(){if(jQuery(this).val()==””) jQuery(this).val(jQuery(this).attr(“placeholder”));});}});} // Ends allowance of jQuery to jQuery shortcut } // Start allowance of jQuery to $ shortcut jQuery(document).ready(function($){ vf_add_gf_placeholders(); }); jQuery(document).bind(‘gform_page_loaded’, function(event, form_id, current_page){ vf_add_gf_placeholders(); }); </script> <?php } add_action(‘wp_head’, ‘gfap_script’); Basically, you only bound the placeholders to the original document ready, but this does not fire on AJAX enabled paged forms. Use the gform_page_loaded hook to make this work for AJAX, as seen above. https://wordpress.org/plugins/gravity-forms-auto-placeholders/
No comments were stored for this source.