Home › Forums › JavaScript › How to call custom jQuery functions via the use of a WordPress filter hook
- This topic is empty.
-
AuthorPosts
-
July 24, 2013 at 5:03 am #144349
sturdybubbles
ParticipantNote: I can’t seem to use greater and less than symbols in my code below.
——————————————————-
So I have some jQuery functions that adjust my column layout on window load and window resize.
They are inside a file called bp-columns.js that looks like this:jQuery(window).load(function () {
columnWidth();
columnHeight();
});jQuery(window).resize( function () {
columnWidth();
columnHeight();
});function columnHeight() {
// code here to calculate and adjust column height
}function columnWidth() {
// code here to calculate and adjust column width
}bp-columns.js is enqueued in my functions.php like so:
function my_scripts() {
wp_enqueue_script( ‘bp-columns’, get_stylesheet_directory_uri() . ‘/js/bp-columns.js’, array( ‘jquery’ ) );
}
add_action( ‘wp_enqueue_scripts’, ‘my_scripts’ );All the above code is working fine.
Now… I have a page that has a Gravity Form on it and I need to recalulate my column layout when form validation occurs to account for the extra height in the content created by validation messages. There is a filter hook for form validation with Gravity Forms.
The following code in my functions.php prints a message to the console successfully when the form is validated.
function custom_validation($validation_result){
<script>
console.log(“Working”);
</script>return $validation_result;
}
add_filter(‘gform_validation’, ‘custom_validation’);*** My question is:
How do I call the functions columnWidth() and columnHeight() whenever form validation occurs?
Any help much appreciated.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.