Helper functions
Function |
Description |
Available since |
Example |
---|---|---|---|
dim |
Blanket management. |
5.4.0 |
AخA AJS.dim(); setTimeout(function () { AJS.undim(); }, 1000); |
undim |
Blanket management. |
5.4.0 |
AJS.dim(); setTimeout(function () { AJS.undim(); }, 1000); |
params Deprecated |
Takes meta tags from the page and populates an object with them. |
5.4.0 |
AJS.populateParameters(); console.log(AJS.params); |
populateParameters Deprecated |
Takes meta tags from the page and populates an object with them. |
5.4.0 |
AJS.populateParameters(); console.log(AJS.params); |
$ |
jQuery. |
5.4.0 |
console.log(AJS.$.fn.jquery); |
Cookie Deprecated |
Store values in a persistent cookie without worrying about the application using too many cookies. |
3.5.5 |
x // Save a value to the conglomerate cookie AJS.Cookie.save("COOKIES_ARE_COOL", "true"); // Save will also update a value previously saved AJS.Cookie.save("COOKIES_ARE_COOL", "not true"); // retrieve a value from the conglomerate cookie AJS.Cookie.read("COOKIES_ARE_COOL"); // remove a value from the conglomerate cookie AJS.Cookie.erase("COOKIES_ARE_COOL"); |
debounce Deprecated |
Ensure that a constantly firing function doesn't cause performance issues. Don't use when binding to an infrequently firing event. |
5.1 |
function myFunction() { //function code } // This function won't fire if it has been less than 300ms before the last call var myDebouncedFunction = AJS.debounce(myFunction, 300); AJS.$(window).resize(myDebouncedFunction); |
debounceImmediate Deprecated |
Like Don't use when binding to an infrequently firing event. |
5.9 |
function myFunction(){ //function code} // This function fires immediately and will not fire again until the last call passes 300ms var myDebouncedFunction = AJS.debounceImmediate(myFunction, 300); AJS.$(window).resize(myDebouncedFunction); |
escapeHtml |
The
|
4.0 |
var url = "\u005C\u003E\u003Cscript\u003Ealert(\u0027XSS\u0027)\u003B\u003C/script\u003E"; // BAD: XSS problem $("#mydiv").html(url); // OKAY $("#mydiv").html(AJS.escapeHtml(url)); // BETTER $("#mydiv").html($.parseHTML(url)); |
log |
A safe alternative to |
1.0 |
AJS.log("Your message here."); |
version |
Returns the version of AUI. |
1.2.0 |
// for peace-of-mind checking AJS.log(AJS.version); // "3.0" // To use it in all its glory if (AJS.version == "3.0") { // take advantage of the awesomeness of AUI 3.0 } else { // write awesome custom code } |