Created
February 17, 2018 04:05
-
-
Save Idealien/77051f03ea91b5b17467d03d32b4b6f5 to your computer and use it in GitHub Desktop.
Gravity Flow - Confirmation dialog before form submit
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
(function (GravityFlowEntryDetail, $) { | |
$(document).ready(function () { | |
if( $('.gravityflow-step-user_input').length ) { | |
//User Input - Save Progress Button | |
if( $('#gravityflow_save_progress_button').length ) { | |
$('#gravityflow_save_progress_button')[0].onclick = null; | |
$('#gravityflow_save_progress_button').click(function() { | |
$('#action').val('update'); | |
$('#gravityflow_status_hidden').val('in_progress'); | |
if( $("#input_26_2").val() == '2.5') { | |
var confirmation = confirm("Are you sure you want to submit field 2 with a value of 2.5?"); | |
if ( confirmation ) { | |
$("#form_26").submit(); | |
} else { | |
return false; | |
} | |
} | |
}); | |
} | |
//User Input - Submit Button | |
if( $('#gravityflow_update_button').length ) { | |
$('#gravityflow_update_button')[0].onclick = null; | |
$('#gravityflow_update_button')[0].click(function() { | |
$('#action').val('update'); | |
$('#gravityflow_status_hidden').val('complete'); | |
if( $("#input_26_2").val() == '2.5') { | |
var confirmation = confirm("Are you sure you want to submit field 2 with a value of 2.5?"); | |
if ( confirmation ) { | |
$("#form_26").submit(); | |
} else { | |
return false; | |
} | |
} | |
}); | |
} | |
} | |
//Approval Submit | |
if( $('.gravityflow-step-approval').length ) { | |
if( $("button[name='gravityflow_approval_new_status_step_58']").length ) { | |
$("button[name='gravityflow_approval_new_status_step_58']").click(function() { | |
if ( $(this).val() == 'approved' && $(".entry-view-field-value:eq(0)").text() == '2.5' ) { | |
var confirmation = confirm("Are you sure you want to approve this entry with field 2 with a value of 2.5?"); | |
if ( confirmation ) { | |
$("#form_22").submit(); | |
} else { | |
return false; | |
} | |
} | |
}); | |
} | |
} | |
}); | |
}(window.GravityFlowEntryDetail = window.GravityFlowEntryDetail || {}, jQuery)); |
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
<?php | |
add_filter( 'gravityflow_enqueue_frontend_scripts', 'action_gravityflow_enqueue_frontend_scripts', 10 ); | |
function action_gravityflow_enqueue_frontend_scripts() { | |
wp_enqueue_script( 'gf-confirm', plugins_url( 'assets/js/gf-confirm.js', __FILE__ ), array( 'jquery', 'gravityflow_entry_detail' ), '1.0.0', true ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The $("#form_XX") is not working. No matter which form I use, it will engage this script. Ideas?