Created
February 25, 2019 18:37
-
-
Save Shelob9/6b9691f1d6cd61323b6c1aad675be8c6 to your computer and use it in GitHub Desktop.
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
/** | |
* Run callback function after a Caldera Forms conditional logic event has transpired | |
* | |
* Required Caldera Forms 1.8.0 or later. | |
*/ | |
jQuery(document).on('cf.form.init', function (event, data) { | |
var state = data.state; | |
//runs whenever a field of this form id enabled | |
state.events.attatchEvent( 'cf.enable', function(fieldIdAttr, formIdAttr){ | |
console.log(fieldIdAttr, formIdAttr); | |
}); | |
//runs whenever a field of this form id disabled | |
state.events.attatchEvent( 'cf.disabled', function(fieldIdAttr, formIdAttr){ | |
console.log(fieldIdAttr, formIdAttr); | |
}); | |
//runs whenever a field of this form id hiden | |
state.events.attatchEvent( 'cf.hide', function(fieldIdAttr, formIdAttr){ | |
console.log(fieldIdAttr, formIdAttr); | |
}); | |
//runs whenever a field of this form id shown | |
state.events.attatchEvent( 'cf.show', function(fieldIdAttr, formIdAttr){ | |
console.log(fieldIdAttr, formIdAttr); | |
}); | |
}); |
it might just be state.events().attatchEvent instead
https://github.com/CalderaWP/Caldera-Forms/blob/master/assets/js/state/state.js#L221
@mdorchain did it work for you like that, state.events().attachEvent()?
I got the same initial error as pless84 mentioned, your fix removed that error, but I'm not seeing any of them fire in the console when fields are conditionally displayed or removed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this: state.events.attatchEvent is not a function