diff --git a/gf.placeholders.js b/gf.placeholders.js
index 5f57aeb..b7d729b 100755
--- a/gf.placeholders.js
+++ b/gf.placeholders.js
@@ -28,7 +28,9 @@ var gf_placeholder = function() {
});
var support = (!('placeholder' in document.createElement('input'))); // borrowed from Modernizr.com
- if ( support && jquery_placeholder_url )
+ var placeholders = $('.gform_fields li.gplaceholder').length;
+
+ if ( placeholders != 0 && support && jquery_placeholder_url ) {
$.ajax({
cache: true,
dataType: 'script',
@@ -40,11 +42,12 @@ var gf_placeholder = function() {
},
type: 'get'
});
+ }
};
$(document).ready(function(){
gf_placeholder();
- $(document).bind('gform_page_loaded', gf_placeholder);
+ $(document).bind('gform_post_render', gf_placeholder);
});
-})(jQuery);
\ No newline at end of file
+})(jQuery);
diff --git a/gravityforms-placeholders.php b/gravityforms-placeholders.php
index ff41c4b..71532c6 100755
--- a/gravityforms-placeholders.php
+++ b/gravityforms-placeholders.php
@@ -3,7 +3,7 @@
Plugin Name: Gravity Forms - Placeholders add-on
Plugin URI: http://github.com/neojp/gravity-forms-placeholders/
Description: Adds HTML5 placeholder support to Gravity Forms' fields with a javascript fallback. Javascript & jQuery are required.
-Version: 1.2.1
+Version: 1.2.3
Author: Joan Piedra
Author URI: http://joanpiedra.com
@@ -13,12 +13,19 @@
*/
if ( isset( $GLOBALS['pagenow'] ) && $GLOBALS['pagenow'] == 'wp-login.php' )
- return;
+ return;
+
+// look into using wp_localize_script instead
+function gf_placeholder_print_scripts() {
+ $plugin_dir = plugin_dir_url( __FILE__ );
+ echo "";
+}
+
+add_action( 'wp_print_scripts', 'gf_placeholder_print_scripts' );
-add_action('wp_print_scripts', 'gf_placeholder_enqueue_scripts');
function gf_placeholder_enqueue_scripts() {
- $plugin_url = plugins_url( basename(dirname(__FILE__)) );
- echo "";
- wp_enqueue_script('_gf_placeholders', $plugin_url . '/gf.placeholders.js', array('jquery'), '1.0' );
-}
\ No newline at end of file
+ wp_enqueue_script( 'gf_placeholders', plugins_url( 'gf.placeholders.js', __FILE__ ), array( 'jquery' ), '1.0.1', true );
+}
+
+add_action( 'wp_enqueue_scripts', 'gf_placeholder_enqueue_scripts' );