Change comment:
There is no comment for this version
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -2,16 +2,22 @@ 2 2 $('#emailForm').on('submit', function () { 3 3 var xwikiForm = $(this); 4 4 var userEmail = $.trim($("#userEmail", xwikiForm).val()); 5 - if (userEmail != '' && this.checkValidity()) { 5 + if (this.checkValidity()) { 6 + // Update and submit the Marketo hidden form. 6 6 var marketoForm = $(".marketoForm"); 7 7 if (marketoForm.length > 0) { 8 8 marketoForm = marketoForm[0]; 9 - $("input[name='Email']", marketoForm).val($("#userEmail", xwikiForm).val()); 10 + // Update. 11 + $("input[name='Email']", marketoForm).val(userEmail); 12 + // Submit the data. 10 10 $(".mktoButton", marketoForm).click(); 11 11 } 15 + // Redirect to the download URL. 12 12 location.href = "$request.downloadURL"; 17 + // Prevent the browser from submitting the form, since we`ve handled it. 13 13 return false; 14 14 } else { 20 + // Let the browser submit the form and display the validation errors natively. 15 15 return true; 16 16 } 17 17 });