ADD_LIBRARY Procedure

This procedure adds the script tag to load a JavaScript library. If a library has been added, it is not added a second time.

Syntax

APEX_JAVASCRIPT.ADD_LIBRARY (
    p_name                   IN VARCHAR2,
    p_directory              IN VARCHAR2,
    p_version                IN VARCHAR2 DEFAULT NULL,
    p_check_to_add_minified  IN BOOLEAN DEFAULT FALSE,
    p_skip_extension         IN BOOLEAN  DEFAULT FALSE,
    p_ie_condition           IN VARCHAR2 DEFAULT NULL,
    p_key                    IN VARCHAR2 DEFAULT NULL);

Parameters

Table 13-7 describes the parameters available in the ADD_LIBRARY procedure.


Table 13-7 ADD_LIBRARY Parameters

Parameter Description

p_name

Name of the JavaScript file. Must not use .js when specifying.

p_directory

Directory where JavaScript library is loaded. Must have a trailing slash.

p_version

Version identifier.

p_check_to_add_minified

If TRUE, the procedure tests if it is appropriate to add .min extension and add it if appropriate. This is added if an application is not running in DEBUG mode, and omitted when in DEBUG mode.

p_skip_extension

If TRUE the extension .js is NOT added.

p_ie_condition

Condition which is used as Internet Explorer condition.

p_key

Name used to indicate if the library has already been loaded. If not specified, defaults to p_directory||p_name||p_version.


Example

The following example includes the JavaScript library file named my_library.1.2.min.js (if the application is not running in DEBUG mode), or my_library.1.2.js (if the application is running in DEBUG mode), from the directory specified by p_plugin.file_prefix. The addition of the .min extension if the application is not running in DEBUG mode is carried out because p_check_to_add_minified is set to true. Since p_skip_extension is not specified, this defaults to .js. Also, since p_key is not specified, the key defaults to p_plugin.file_prefix||mylibrary.1.2.

apex_javascript.add_library (
    p_name                  => 'mylibrary.1.2',
    p_directory             => p_plugin.file_prefix,
    p_check_to_add_minified => true );