AE JS Events Reference

You can optionally define and set up event handlers through the event addHandler method. This article provides a reference of the available events.

As an example of usage, here is some JavaScript that calls some events:

<script>
            //locally defined handlers
            function loginHandler(user) {
              console.log("LOGIN HANDLER");
              console.log(user);
            }
          
            function AEJSReady(aeJS) {
              //attach local handlers to events
              aeJS.events.onFlow.addHandler(flowHandler);
              aeJS.events.onLogin.addHandler(loginHandler);
              aeJS.events.onWindow.addHandler(windowHandler);
            }
          </script>

Note that this article refers back to AE JS Settings and AE JS Methods & Triggers.



aeJS.events.onActivitySent

Event is triggered at successful completion of the trigger.send_activity method. See the AE JS Methods & Triggers Reference for more information.

Parameters

response: Associated data structure for response from send_activity call. Either OK, a new activity record, or an error.



aeJS.events.onEmailVerify

Event is triggered at different steps of custom email verification.

Parameters

sent: Triggered initiated via a successful call to trigger.send_verify_email. Returns sent or verified. For example: {'EmailAddress', 'ActivationCode'} 

verified: Triggered on the callback page defined in trigger.send_verify_email or the default return_url in settings. Returns the associated data structure for the step. For example: {'MemberID', 'MemberServiceID', 'EmailAddress', 'ActivationCode', 'Service'}

 


aeJS.events.onFlow

Event is triggered at each distinct step of registration flow.

Parameters

step: is an object containing information on current step in flow and associated data. 

Example:

{step: "login", auth_url: "<a href="http://beta.theappreciationengine.com/framework/flow/422/login" rel="nofollow noopener noreferrer" target="_blank">http://beta.theappreciationengine.com/framework/flow/422/login</a>", return: "<a href="http://squared99.com/new_framework2.html#" rel="nofollow noopener noreferrer" target="_blank">http://squared99.com/new_framework2.html#</a>", service: "twitter"}




aeJS.events.onLogin

Event is triggered on successful login.

Parameters

user: object containing profile information on currently logged in user. 

type: login or registration. If returning from login, flow will be login. If returning from registration, flow will be registration. The default value is login.

sso: Boolean value indicated whether onLogin event fired due to single sign-on event. The existing user that had previously signed on with framework.

Example user: 

{"data": {"firstname": "Jeff","surname": "Mitchell","email": "XX","gender": "M","age": "39","id": 7,"avatarurl": "<a href="http://theappreciationengine.com/Member_Controller/getAvatar/7%22,%22country" rel="nofollow noopener noreferrer" target="_blank">http://theappreciationengine.com/Member_Controller/getAvatar/7","country</a>": null,"city": null,"countrycode": null},"services": [{"service": "twitter","valid": "1","id": "4374025","userid": "36905641","username": "squared99","userurl": "<a href="http://twitter.com/squared99%22,%22token%22:%22XX%22,%22tokensecret" rel="nofollow noopener noreferrer" target="_blank">http://twitter.com/squared99","token":"XX","tokensecret</a>": "XX","lastupdated": null,"verifiedemail": null,"paidaccount": "0","followers": "0","likes": "0"}]},




aeJS.events.onLoaded

Event is triggered after all initialization and required preparation calls have been made by AE JS. This differs from the AEJSReady call, which is triggered upon successful script load. The onLoadedevent handler must be defined within the AEJSReady function.

Parameters

aeJS: An object that contains the framework reference in its current state.




aeJS.events.onOptin

An event triggered at successful completion of trigger.optin.

Parameters

response: Associated data structure for response from optin call. Either OK, a user record, or an error.





aeJS.events.onPasswordReset

An event triggered after trigger.reset_password is called.

Parameters

status: Returns ok or error

message: If the status is error, this is associated message.





aeJS.events.onUser

Event is triggered if user session exists on page load.

Parameters

user : An object containing profile information on currently logged in user. 

state: Returns init or update. It will always return initif member session is active on page load. update is fired in cases where the member record has been updated, such as in the case of a custom form submission with the data-ae-register-formattribute.

Example user: 

{"data": {"firstname": "Jeff","surname": "Mitchell","email": "XX","gender": "M","age": "39","id": 7,"avatarurl": "<a href="http://theappreciationengine.com/Member_Controller/getAvatar/7%22,%22country" rel="nofollow noopener noreferrer" target="_blank">http://theappreciationengine.com/Member_Controller/getAvatar/7","country</a>": null,"city": null,"countrycode": null},"services": [{"service": "twitter","valid": "1","id": "4374025","userid": "36905641","username": "squared99","userurl": "<a href="http://twitter.com/squared99%22,%22token%22:%22XX%22,%22tokensecret" rel="nofollow noopener noreferrer" target="_blank">http://twitter.com/squared99","token":"XX","tokensecret</a>": "XX","lastupdated": null,"verifiedemail": null,"paidaccount": "0","followers": "0","likes": "0"}]},




aeJS.events.onLogout

An event is triggered on successful logout.

Parameters

null



aeJS.events.onServiceRemoved

This event is triggered on removal of service through data-ae-remove-link or aeJS.trigger.remove.

Parameters

service: String for the service removed. For example: facebook

user: An object containing profile information on currently logged in user.



aeJS.events.onWindow

This event is triggered at close and open of modal windows.

state: An object containing type (popup or modal) and the current state (open or closed) of window.

Example:

{type: "popup", state: "opened", service: "twitter"}"




aeJS.events.onMobileDetect

This event is triggered if current browser session is determined to be from a tablet or mobile device.

Parameters

null 




How did we do?