Show:

F2.Constants.AppHandlers Class

A convenient collection of all available appHandler events.

Properties

Name Description
APP_CREATE_ROOT static

Equivalent to appCreateRoot. Identifies the create root method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

APP_DESTROY static

Equivalent to appDestroy. Identifies the app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

APP_DESTROY_AFTER static

Equivalent to appDestroyAfter. Identifies the after app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

APP_DESTROY_BEFORE static

Equivalent to appDestroyBefore. Identifies the before app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

APP_RENDER static

Equivalent to appRender. Identifies the app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig, appHtml )

APP_RENDER_AFTER static

Equivalent to appRenderAfter. Identifies the after app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

APP_RENDER_BEFORE static

Equivalent to appRenderBefore. Identifies the before app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

APP_SCRIPT_LOAD_FAILED static

Equivalent to appScriptLoadFailed. Identifies the app script load failed method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig, scriptInfo )

Properties

APP_CREATE_ROOT String final static

Equivalent to appCreateRoot. Identifies the create root method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_CREATE_ROOT,
    function(appConfig)
    {
        // If you want to create a custom root. By default F2 uses the app's outermost HTML element.
        // the app's html is not available until after the manifest is retrieved so this logic occurs in F2.Constants.AppHandlers.APP_RENDER
        appConfig.root = jQuery('<section></section>').get(0);
    }
);

APP_DESTROY String final static

Equivalent to appDestroy. Identifies the app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_DESTROY,
    function(appInstance)
    {
        // call the apps destroy method, if it has one
        if(appInstance && appInstance.app && appInstance.app.destroy && typeof(appInstance.app.destroy) == 'function')
        {
            appInstance.app.destroy();
        }
        else if(appInstance && appInstance.app && appInstance.app.destroy)
        {
            F2.log(appInstance.config.appId + ' has a destroy property, but destroy is not of type function and as such will not be executed.');
        }

        // fade out and remove the root
        jQuery(appInstance.config.root).fadeOut(500, function() {
            jQuery(this).remove();
        });
    }
);

APP_DESTROY_AFTER String final static

Equivalent to appDestroyAfter. Identifies the after app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_DESTROY_AFTER,
    function(appInstance)
    {
        F2.log(appInstance);
    }
);

APP_DESTROY_BEFORE String final static

Equivalent to appDestroyBefore. Identifies the before app destroy method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appInstance )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_DESTROY_BEFORE,
    function(appInstance)
    {
        F2.log(appInstance);
    }
);

APP_RENDER String final static

Equivalent to appRender. Identifies the app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig, appHtml )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_RENDER,
    function(appConfig, appHtml)
    {
        var $root = null;

        // if no app root is defined use the app's outer most node
        if(!F2.isNativeDOMNode(appConfig.root))
        {
            appConfig.root = jQuery(appHtml).get(0);
            // get a handle on the root in jQuery
            $root = jQuery(appConfig.root);                
        }
        else
        {
            // get a handle on the root in jQuery
            $root = jQuery(appConfig.root);            

            // append the app html to the root
            $root.append(appHtml);
        }            

        // append the root to the body by default.
        jQuery('body').append($root);
    }
);

APP_RENDER_AFTER String final static

Equivalent to appRenderAfter. Identifies the after app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_RENDER_AFTER,
    function(appConfig)
    {
        F2.log(appConfig);
    }
);

APP_RENDER_BEFORE String final static

Equivalent to appRenderBefore. Identifies the before app render method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_RENDER_BEFORE,
    function(appConfig)
    {
        F2.log(appConfig);
    }
);

APP_SCRIPT_LOAD_FAILED String final static

Equivalent to appScriptLoadFailed. Identifies the app script load failed method for use in AppHandlers.on/off. When bound using F2.AppHandlers.on() the listener function passed will receive the following argument(s): ( appConfig, scriptInfo )

Example:

var _token = F2.AppHandlers.getToken();
F2.AppHandlers.on(
    _token,
    F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
    function(appConfig, scriptInfo)
    {
        F2.log(appConfig.appId);
    }
);