EPiServer Forms JS API

Member since: 2012

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
  • Member since: 2012

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

    #144526 Feb 15, 2016 12:07
  • Member since: 2009

    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
  • Member since: 2009
This topic is locked because the last reply was posted more than 6 months ago. Please contact epw@episerver.com to unlock it.