On 03/05/07, jdalton <[EMAIL PROTECTED]> wrote:
>
> Hello Richard,
>
> First, this is not a $A() issue.
>
> When you called ''With Reporter' you wont get scritpaculous because
> your code is
> executing before scriptaculous is even rendered via the dom. (top
> down)
>
> The dom should be there onLoad though. If not try:
>
> Event.observe(window, 'load', function(){
> setTimeout(function(){
> ReportJS('AfterLoad');
> }, 100);
> });
>
> Maybe dynamically added scripts need time to be seen in the dom,
> I used 100 miliseconds, but if that works i am sure any amount would
> like 10.
>
>
> >
>
Hi. Thanks for the comments but I think I've not explained myself well enough.
Follow this through.
<html>
<head>
<script tag with src to prototype.js>
<script tag with src to scriptaculous.js which will automatically load
the sub files>
<script tag with src to my library.js which mimics scriptaculous's
load() method for my sub files>
</head>
...
Nothing special in terms of timing is needed for scriptaculous to
work, even though it is dependent upon prototype.
My library is dependent upon scriptaculous and uses the SAME mechanism
to load additional sub files.
My code doesn't fail due to scriptaculous NOT being loaded (if it
couldn't find scriptaculous it would raise an error, just like
scriptaculous would if it couldn't find prototype).
In MY copy of the load() method, the result of
$A(document.getElementsByTagName("script")) does not include
____MY____ script tag, EVEN THOUGH THE REPORTING OF THE SCRIPTS IS
ACTUALLY IN MY SCRIPT!!!!
The issue __is__ caching.
Here is my script...
========raq.js============
var RAQ_Common =
{
Version: '1.0.1',
load: function()
{
if
(
(typeof Scriptaculous=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
parseFloat(Scriptaculous.Version.split(".")[0] + "." +
Scriptaculous.Version.split(".")[1]) < 1.7
)
{
throw("Richard Quadling's library requires the Scriptaculous
library >= 1.7.0");
}
// This is the problem line. The CURRENT script will NOT be found.
// Instead a cached version of the results will be found.
$A(document.getElementsByTagName("script")).findAll
(
function(s)
{
//Proof - the raq.js script will NOT be reported upon.
console.info(s);
return (!!s.src && s.src && s.src.match(/raq\.js(\?.*)?$/))
}
).each
(
function(s)
{
var path = s.src.replace(/raq\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
(
includes
? includes[1]
:
'additionalJS,enhanced_date,enhanced_element,enhanced_event,enhanced_math,enhanced_string'
).split(',').each
(
function(include)
{
Scriptaculous.require(path+include+'.js')
}
);
}
},
}
RAQ_Common.load();
and a new HTML file
===========js_write.html============
<html>
<head>
<script type="text/javascript"
src="/global/javascript/prototype/prototype.js"></script>
<script type="text/javascript"
src="/global/javascript/script.aculo.us/scriptaculous.js"></script>
<script type="text/javascript"
src="/global/javascript/rquadling/raq.js"></script>
<title>JS Test</title>
</head>
<body>Hello</body>
</html>
With this code, my console now reads ...
<script src="/global/javascript/prototype/prototype.js" type="text/javascript">
<script src="/global/javascript/script.aculo.us/scriptaculous.js"
type="text/javascript">
But this is being reported from MY code which is loaded via <script
type="text/javascript"
src="/global/javascript/rquadling/raq.js"></script>
If I swap raq.js and scriptaculous around (and remove the dependency),
scriptaculous won't load all of its files as it won't be able to find
its own tag in the $A() results.
In re-reading your comments about the dynamically loaded scripts, I
think I see what I've not explained properly.
I'm not interested in the sub files that scripaculous loads. What I
have is scriptaculous makes the first call to $A to get the SCRIPTs.
When my code which is loaded via the normal mechanism of a SCRIPT tag,
the same call to get the list of loaded scripts doesn't include the
script CURRENTLY executing.
I can understand that the subscript from scriptaculous may not be
present and this I can understand as being related to the DOM needing
updating, but that is NOT the issue.
This is a caching issue. Ideally I would like to flush the cache
prior to the my call. If I can do that, then I am confident that this
will work as expected.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---