load_script
- AbstractItem.load_script(js_filename, callback, onload)
- Domain:
client
- Language:
javascript
- Class:
Execution:
asynchronous
Description
Use load_script method to load javascript file from the server, before executing callback.
The method checks whether the file has been loaded, if not, loads it from the server, executes (if specified) onload function and then executes the callback, otherwise just the callback function is executed.
The item is passed to the callback function as a parameter.
Attention
The js_filename should specify the path to javascript file relative to the server directory.
The request to the server is executed asynchronously.
Paramaters
Parameter |
Type |
Description |
|---|---|---|
|
|
Filename script to load. The |
|
|
callback function. |
|
|
Function executed (if specified) before the callback. |
Example
Bellow, the do_some_work function is executed only when lib.js file from server js directory has been loaded:
function some_work(item) {
item.load_script('js/lib.js', do_some_work);
}
function do_some_work(item) {
// some code
}
See also
Related functions
Related concepts