Last active
May 27, 2021 19:59
-
-
Save danieliser/6bd3e476c01ac7d2c3abce6cd0f4e7cb to your computer and use it in GitHub Desktop.
Add a mass click trigger to many links and insert that links url into the popup forms field, then on submission redirect to specific url.
This file contains 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 characters
// Customize the click selector (.pdf-link). Elements targeted by this script should not be set up as normal click triggers. | |
// This effectively acts as the click trigger. | |
jQuery(document).on('click', '.pdf-link', function (e) { | |
var popupID = 123, // Popup ID # | |
linkFieldName = 'link_field_name_attr', // Form field name="" value. | |
// Stop editing below this line. | |
// --------------------------------------- | |
$popup = PUM.getPopup(popupID), // Change this to your popup ID. | |
$i | |
$this = $(event.target); | |
e.preventDefault(); | |
// If the popup is already open return. | |
if ($popup.popmake('state', 'isOpen')) { | |
return; | |
} | |
// If cookie exists or conditions fail return. | |
if ($popup.popmake('checkCookies', {cookie_name: 'pum-'+popupID}) || !$popup.popmake('checkConditions')) { | |
return; | |
} | |
// Set the global last open trigger to the a text description of the trigger. | |
$.fn.popmake.last_open_trigger = $this; | |
// Set the value of hidden NF field to the clicked links url. | |
$popup.find('[name="'+formInputName+'"]').val($this.attr('href')); | |
// Open the popup. | |
$popup.popmake('open'); | |
}); |
This file contains 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 characters
<script> | |
setTimeout(function() { | |
window.location = "{{link_field_value}}"; // Output the value of the field used in your code above into the script to redirect. | |
}, 3000); // Change this to delay the redirect/download. Currently 3 seconds. | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment