Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;(function$) {
- $.plugin2 = function(el, options) {
- ...
- ...
- var init = function() {
- plugin.settings = $.extend({}, defaults, options);
- plugin.el = el;
- var init = function() {
- ...plugin1Instance.settings.variable... <--------
- }
- init();
- };
- });
- var plugins = [];
- function startOnLoad() {
- // Start init() of every 'registered; plugin
- for (var i = 0; plugins.length - 1; i++) {
- plugins[i]();
- }
- // Ok, all plugins initialized, can access each other.
- // Ex: plugin1Instance.settings.variable and etc.
- }
- plugins.push(Plugin1.init);
- var windowOnLoad = function() {
- // your plugins should be loaded at the moment
- }
- if (window.addEventListener) {
- window.addEventListener('load', windowOnLoad, false);
- } else if (window.attachEvent) {
- window.attachEvent('onload', windowOnLoad);
- }
- var totalPlugins = 2;
- var numberOfLoadedPlugins = 0;
- var pluginLoaded = function() {
- numberOfLoadedPlugins += 1;
- if(numberOfLoadedPlugins === totalPlugins) {
- // it's done. your plugins are loaded
- // proceed with the other logic
- }
- }
- ;(function$) {
- $.plugin1 = function(el, options) {
- // ...
- };
- pluginLoaded();
- });
- ;(function$) {
- $.plugin2 = function(el, options) {
- // ...
- };
- pluginLoaded();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement