|
Category /
UnverseJSSummary: Information about how different Unverse plugins can coexist This category contains recipes using the Unverse JavaScript library. The current release 10.02 may not work well if it is called more than once, and the docReady() function will not work multiple times. For this reason, developers of plugins built with Unverse need to coordinate in order to coexist. First, include the unverse.js script with your recipe. Second, to make sure the skin includes unverse.js only once, we use the same key for the HTML headers. In your-recipe.php use this snippet: SDVA( The Third, in order to run multiple functions on page load, use the following snippet at the beginning of your JavaScript file: if (typeof _.dRF == 'undefined') _.dRF = []; // init docReadyFunctions
function docReady(){ for(var i=0; i<_.dRF.length; i++) _.dRF[i](); } // run them
This snippet instructs Unverse to run all functions contained in the _.dRF[] array. That means that we can add our functions to this array without destroying previously defined functions. Fourth, we add our own functions to the _.dRF[] array:
_.dRF.push(function(){ // new docReadyFunction
// here my code run on startup.
});
If you have any questions, contact me (Petko). Information about how different Unverse plugins can coexist
|