ri_gfdp_js

The Gravity Forms Data Persistence Add-On Reloaded ri gfdp js function.

Description

ri_gfdp_js(); 

Usage

  1. if ( !function_exists( 'ri_gfdp_js' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms-data-persistence-add-on-reloaded/gravity-forms-data-persistence-add-on-reloaded.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ri_gfdp_js(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/gravity-forms-data-persistence-add-on-reloaded.php  
  1. function ri_gfdp_js() { 
  2. $ajax_interval = apply_filters('gfdp_ajax_interval', 10000); 
  3. ?> 
  4. <script type="text/javascript"> 
  5. var changed = false; 
  6.  
  7. function gfdp_events() { 
  8. jQuery('form.gfdp').live('change keyup', function () { 
  9. changed = true; 
  10. }) 
  11.  
  12. jQuery(document).ready(gfdp_events); 
  13. jQuery(document).ajaxComplete(gfdp_events); 
  14.  
  15.  
  16. function gfdp_ajax($) { 
  17. if (changed == true) { 
  18. var data = { 
  19. 'action': 'gfdp_save',  
  20. 'form': jQuery('form.gfdp').serialize() 
  21. }; 
  22.  
  23. jQuery.ajax({ 
  24. url: '<?php echo admin_url('admin-ajax.php'); ?>',  
  25. type: 'POST',  
  26. data: data,  
  27. success: function (response) { 
  28. changed = false; 
  29. }) 
  30. }; 
  31.  
  32. jQuery(document).ready(setInterval(gfdp_ajax, <?php echo $ajax_interval; ?>)); 
  33. </script> <?php