Jam.py documentation

load_module

load_module(callback)

domain: client

language: javascript

class AbstractItem

Description

Use load_module method to dynamically load javascript file of an item module, before executing callback.

The method checks whether the module has been loaded, if not, loads the module from the server, initializes the item and then executes the callback function, otherwise just the callback function is executed. The item is passed to the callback function as a parameter.

The request to the sever is executed asyncroniously.

Example

Bellow, the do_some_work function is executed only when an item module has been loaded:

function some_work(item) {
    item.load_module(do_some_work);
}

function do_some_work(item) {
    // some code
}