Hi,

Sorry, I just found a mistake in my solution code:

> jQuery.plugin = function(name) {
>       var p = jQuery.plugins;
>       var n = name.split('.');
>       for( var i = 0; i < n.length; i++ ) {
>               if( !p[n[i]] ) p[n[i]] = {};
>               p = p[n[i]];
>       }
>       p[n].available = true;
> }

That should be
        p.available = true;
of course.

That code can easily be changed to support other Information about the 
plugins, like e.g. version numbers:

jQuery.getPluginVersion = function(name) {
        var n = (name).split('.'), j;
        for( j = 0; p && j < n.length; j++) {
                if( !p[n[j]] )
                        throw "required plugin " + ns[i] + " not found";
                p = p[n[j]];
        }
        return p.version;
}
jQuery.plugin = function(name,version) {
        var p = jQuery.plugins;
        var n = name.split('.');
        for( var i = 0; i < n.length; i++ ) {
                if( !p[n[i]] ) p[n[i]] = {};
                p = p[n[i]];
        }
        p[n].available = true;
        p[n].version = version?parseFloat(version):0;
}

// Usage:
$.checkForPlugins('autocomplete,dimensions,myplugin.part1');
if( $.getPluginVersion('myplugin.part1') < 42.2 )
        throw "get a current Version of myplugin!";

// at the end of the plugin:
$.plugin('myplugin.part1',42.5);

Christof

Reply via email to