Last active
November 28, 2018 18:26
-
-
Save noahub/cab64fcf0b05ead054be1ecc01cf6fe9 to your computer and use it in GitHub Desktop.
Revisions
-
Noah revised this gist
Sep 28, 2018 . 1 changed file with 13 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ <script type="text/javascript"> //runs on form submission function yourSubmitFunction(e, $) { e.preventDefault(); try { @@ -15,15 +16,6 @@ function yourSubmitFunction(e, $) { } } //ga form submission event function gaForm(event) { var $form, $formContainer, params; @@ -53,4 +45,16 @@ function gaForm(event) { } }; //waits until window load to initialize lp.jQuery(window).load(function(){ lp.jQuery(function($) { $('.lp-pom-form .lp-pom-button').unbind('click tap touchstart').bind('click.formSubmit tap.formSubmit touchstart.formSubmit', function(e) { if ( $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $); }); $('form').unbind('keypress').bind('keypress.formSubmit', function(e) { if(e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' && $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $); }); }); }); </script> -
Noah revised this gist
Sep 26, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function yourSubmitFunction(e, $) { } lp.jQuery(function($) { $('.lp-pom-form .lp-pom-button').unbind('click tap touchstart').bind('click.formSubmit tap.formSubmit touchstart.formSubmit', function(e) { if ( $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $); }); $('form').unbind('keypress').bind('keypress.formSubmit', function(e) { -
Noah revised this gist
Sep 21, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,6 +32,7 @@ function gaForm(event) { $formContainer = lp.jQuery(event.currentTarget).closest('.lp-pom-form'); $form = $formContainer.children('form'); if ($form.valid()) { if(typeof eventTracker !== 'undefined'){ if (!eventTracker._isGaLoaded()) { return $form.submit(); } @@ -46,7 +47,10 @@ function gaForm(event) { return $form.submit(); } }); }else{ return $form.submit(); } } }; </script> -
Noah revised this gist
Aug 28, 2017 . 1 changed file with 26 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,7 @@ function yourSubmitFunction(e, $) { } finally { // This submits the form. If your code is asynchronous, add to callback instead gaForm(e); lp.jQuery('.lp-pom-form form').submit(); } } @@ -23,4 +24,29 @@ lp.jQuery(function($) { yourSubmitFunction(e, $); }); }); //ga form submission event function gaForm(event) { var $form, $formContainer, params; event.preventDefault(); event.stopPropagation(); $formContainer = lp.jQuery(event.currentTarget).closest('.lp-pom-form'); $form = $formContainer.children('form'); if ($form.valid()) { if (!eventTracker._isGaLoaded()) { return $form.submit(); } params = lp.jQuery.extend({ category: 'Form', action: 'Submit', label: "#" + ($formContainer.attr('id')) }, $formContainer.data('ubGAParams')); eventTracker._logEvent(params); return ga('send', 'event', params.category, params.action, params.label, { hitCallback: function() { return $form.submit(); } }); } }; </script> -
Noah created this gist
Mar 29, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <script type="text/javascript"> function yourSubmitFunction(e, $) { e.preventDefault(); try { //ADD CUSTOM CODE HERE } catch(err) { //code to handle errors. console.log is just an example console.log(err); } finally { // This submits the form. If your code is asynchronous, add to callback instead lp.jQuery('.lp-pom-form form').submit(); } } lp.jQuery(function($) { $('.lp-pom-form .lp-pom-button').unbind('click tap touchstart').bind('click.formSubmit', function(e) { if ( $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $); }); $('form').unbind('keypress').bind('keypress.formSubmit', function(e) { if(e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' && $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $); }); }); </script>