Hello Richard,
This is the source of $A:
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 it caches values.
If you mimic scriptaculous's loader you shouldn't be having an issue.
I have done so many times with no issues. I notice you use findAll()
instead of find().
Here are my working examples:
/* * * * * * * * * * * * * * * * * * *
*
* 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
-~----------~----~----~----~------~----~------~--~---