Appreciation Engine

Open navigation

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);
    }

    //attach local handlers to events
    function AEJSReady(aeJS) {
        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.






Table Of Contents







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 sinle sign-on event. This is an existing user that had previously signed on using the same framework.


Example user: 

[
    "data": {
        "firstname": "Jeff",
        "surname": "Mitchell",
        "email": "XX",
        "gender": "M",
        "age": "39",
        "id": 7,
        "avatarurl": "http://theappreciationengine.com/Member_Controller/getAvatar/7",
        "country": null,
        "city": null,
        "countrycode": null
        },

    "services": {
         "service": "twitter",
         "valid": "1",
         "id": "4374025",
         "userid": "36905641",
         "username": "squared99",
         "userurl": "http://twitter.com/squared99",
         "token":"XX",
         "tokensecret":"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.onActivitySharing


Event is triggered after response from trigger.activity_sharing is returned.



Parameters


response: Associated data structure for response. A user record, or an error.




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": "http://theappreciationengine.com/Member_Controller/getAvatar/7",
        "country": null,
        "city": null,
        "countrycode": null
        },

    "services": {
         "service": "twitter",
         "valid": "1",
         "id": "4374025",
         "userid": "36905641",
         "username": "squared99",
         "userurl": "http://twitter.com/squared99",
         "token":"XX",
         "tokensecret":"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 






aeJS.events.onFollow


This event is triggered after a follow event


Response:

{
    "service": "spotify",
    "followed": true,
    "follow_type": "artist",
    "follow_id": "2ApaG60P4r0yhBoDCGD8YG",
    "message": "Successfully followed artist with id 2ApaG60P4r0yhBoDCGD8YG"
}     


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.