Here is the source for $A method:
var $A = Array.from = function(iterable) {
if (!iterable) return [];
if (iterable.toArray) {
return iterable.toArray();
} else {
var results = [];
for (var i = 0, length = iterable.length; i < length; i++)
results.push(iterable[i]);
return results;
}
};
Please show me where the "caching" occurs.
If you mimic the scriptaculous loader you shouldn't have any problems.
I noticed your code was using findAll() instead if find().
I use the approach alot and have not had any issues:
/* * * * * * * * * * * * * * * * * * *
*
* Load Common Classes
*
* * * * * * * * * * * * * * * * * * */
(function(){
var require = function(libraryName) {
document.write('<script type="text/javascript" src="'+libraryName
+'"></script>');
};
var script =
$A(document.getElementsByTagName("script")).find( function(s){
return (s.src && s.src.match(/common\.js(\?.*)?$/));
});
var path = script.src.replace(/common\.js(\?.*)?$/,'');
var includes = ['script1','script2','script3'];
includes.each(function(include){
require( path + include + '.js');
});
})();
OR
/* * * * * * * * * * * * * * * * * * *
*
* Controls (Singleton)
*
* * * * * * * * * * * * * * * * * * */
Controls = {
require : function(libraryName) {
document.write('<script type="text/javascript" src="'+libraryName
+'"></script>');
},
load : function(){
var script =
$A(document.getElementsByTagName("script")).find( function(s){
return (s.src && s.src.match(/controls\.js(\?.*)?$/));
});
var path = script.src.replace(/controls\.js(\?.*)?$/,'');
var includes = script.src.match(/\?.*load=([a-z,]*)/i);
includes = (includes? includes[1] :
'control1,control2,control3').split(',');
includes.each(function(include){
Controls.require( path + include + '.js');
});
}
};
Controls.load();
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---