November Happy Hour will be moved to Thursday December 5th.

EPiServer Forms JS API

Vote:
 

I am looking at documentation for BETA: http://world.episerver.com/add-ons/episerver-forms/handling-events-for-episerver-forms/

It says that there is an $$epiforms object, but in latest version there is no such. Now my code which handled events broke after update - it used $$epiforms.

How to handle events in latest version?

#144513
Feb 15, 2016 8:25
Vote:
 

It was JS error which caused $$epiforms to not load.

#144526
Feb 15, 2016 12:07
Vote:
 

Please ensure you don't  have issue like this http://world.episerver.com/forum/developer-forum/Addons/Thread-Container/2016/2/episerver-forms-not-using-ajax-mode/

This is JS sample code to handle all client-side epiforms events in AlloyMVC

<script>

   if (typeof $$epiforms !== 'undefined') {

       $$epiforms(document).ready(function myfunction() {

           console.log('listen to event');

           $$epiforms(".EPiServerForms").on("formsNavigationNextStep formsNavigationPrevStep formsSetupCompleted formsReset formsStartSubmitting formsSubmitted formsSubmittedError formsNavigateToStep formsStepValidating", function (event, param1, param2) {

               console.log($(this).get(0), event);

           });

       });

   }

</script>



 

Listen for formsLoadExternalScripts and formsLoadExternalCss events

<script>

   if (typeof $$epiforms !== 'undefined') {

       console.log('listen to event');

       $$epiforms(".EPiServerForms").on("formsLoadExternalScripts formsLoadExternalCss", function (event, param1, param2) {

               console.log($(this).get(0), event);

           });

   }

</script>



 

For QuickSilver site, you should put the script before  @Html.RequiredClientResources("Footer")

 

the jQuery event object contains information about

  • type: type of the event
  • working form DOM element: the DOM element raises the event
  • workingFormInfo: contains all meta information of current EPiServer Forms
  • formData: in some submitting-related events, this property will contain the standard FormData object of the submission


These event are kind of notification-only, they don't support cancel the ongoing action.

#144739
Edited, Feb 18, 2016 11:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.