-
-
Notifications
You must be signed in to change notification settings - Fork 10
Javascript Reference
The ExpressionEngine Developer Toolbar (EEDT) loads a javascript library called eedt.js. The eedt.js library handles the entire EEDT lifecycle but also exposes an API that allows you to do the following:
- Listen for toolbar events, such as init and ready
- Listen for panel events, such as init, open and close
- Communicate via AJAX with server side PHP scripts
- Dynamically load CSS & JS assets
The library is available as the eedt JS global object.
eedt.ready(callback)
-
callback - Function to be invoked when
eedtlibrary is ready
Specify a function to be called when the eedt library is fully loaded. Callback recieves two arguments: jQuery object and the eedt object.
Since the eedt.js library depends on jQuery (and will load it dynamically if not present on the page) this method is useful for running code that depends on jQuery being present or that needs to communicate with PHP scripts using the eedt.ajax() method.
Example
eedt.ready(function($, eedt){
//Code
})eedt.ajax(class_name, method_name [, callback])
- class_name - Name of PHP class to be loaded and instantiated
- method_name - Name of PHP method to be called
- callback - Optional, Function to be invoked on request finishes
- returns - jQuery.Deferred
Perform an asynchronous HTTP (AJAX) request with a specified PHP class & method.
Callback receives a single argument: the returned data from the PHP script.
NB: EEDT implements a security protocol whereby the class specified in the class_name argument must have a public array property called $eedt_act that contains a list of all method names that can be called by the eedt library. If the class specified does not contain the method name specified in the method_name argument, an error will be returned.
Example