Yes, I was concerned about having to much stuff resident in memory as
would be the case with continually loading via ajax.updater and using
eval scripts...
You could use unique IDs for each of your required JS files and then
one for the "Modules" or "Widgets" in your case..
you could then call this like LoadJS(file, scriptid) --- // you would
need to modify the function of coarse...
That way you could be loading more than just one file per call and
you could load the dependent files as the first lines of the widget.js
Does that make any sense??
You could get more fancy and look at each script tag and see if the
dependent file is already loaded based on the src, if not load it. .
That way you get rid of the ID all together. It would be an
equivalent to PHPs require_once() function.
______________________________________________________________________
Alex Duffield ❖ Principal ❖ InControl Solutions . http://
www.incontrolsolutions.com
On 2-Jun-07, at 1:54 AM, Thomas K. Nielsen wrote:
>
>> function LoadJS(file){
>> var head = document.getElementsByTagName('head').item(0)
>> var scriptTag = $('loadScript');
>> if(scriptTag) head.removeChild(scriptTag);
>> script = document.createElement('script');
>> script.src = file;
>> script.type = 'text/javascript';
>> script.id = 'loadScript';
>> head.appendChild(script)
>> }
>
> Thanks for the suggestions guys.
> I used a similar approach as this - not calling it the same however -
> but the problem with that - at least for me was that I have multiple
> js files and some are dependent on each other - so I need to be sure
> that they are avilable and ready to be used once they are used.
>
> I actually did try it with the Ajax.Updater - and I could load the
> files (or at least the javascript) - it's getting loaded immediately
> and is accessible, but I'm not sure it's a good solution - it's
> getting hard to keep track of what is loaded :) if I go through it
> with the debugger - I only see it as evalcode. So I think I will keep
> away from that approach.
>
> To the guys that suggested that I handle it on the server - that's not
> an option - I have to do it clientside - or hardcode the files into
> the head section of each page.
>
> Thanks for the input - much appreciated
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---