I have tried the new Function approach but it doesn't work.

I actually my first "proof of concept" (if we can call it that)
working, but it was not very pretty and sometimes a file will not load
properly which would result in a widget being broken and/or not
displayed. Mostly on FF3 tho for some reason.

http://codeserenity.com/jquery/scriptless/js/jquery.scriptless.js - is
actually quite fast, but not great and can be broken

http://codeserenity.com/jquery/scriptless/js/jquery.scriptless3.js -
was made so nothing get broken, bit slower than above but no widget is
ever broken, only down side is it doesn't work with IE when the
initialization commands are evaled (the getScript get evaled just
fine)

I think it's mostly because for some reason $.accordion for example
doesn't exists within the eval but outside of it, when the original $
of JQuery does. Or well that's what I think with the little knowledge
i have about javascript.

So now I am kind of trying to mix the 2 together, where the look up is
like in 3, with CSS3 substring selector
http://codeserenity.com/jquery/scriptless/js/jquery.scriptless6.js
(there is 6 version already lol, at least I don't let go)

But now the issue is that if core doesn't load fast enough it wont
work. So I need the getScript cascade really. What I was thinking of
doing tho is inside the last egtScript eval a function instead, maybe
a method with the plugin than then take the initialization commands
and start them then.

So basically as long as that function can exsist within the eval and
be recognise hopefully it will launch and the commands will run where
they are actually declared (or something like that)

Sorry if that make little sense only, still need to learn a lot of the
javascript terminology :)

Also could you explain what  $.getScript(scripts[n++],
arguments.callee);  actually does? I am not sure of what
arguments.callee refers to.

Thanks for the help and feedback so far guys, it is really
appreciated.

Gilles.

On Mar 29, 12:14 am, Ricardo <[email protected]> wrote:
> You could drop the evaling altogether:
>
> var scripts = [
>         'js/ui.core.js',
>         'js/ui.dialog.js',
>         'js/ui.tabs.js',
>         'js/ui.datepicker.js',
>         'js/ui.resizable.js',
>         'js/ui.accordion.js'],
>         n = 0;
>
> $.getScript(scripts[n++], function(){
>     if (scripts[n]) {
>        $.getScript(scripts[n++], arguments.callee);
>     } else {
>        $('#foo1').dialog({...});
>        $('#foo2').tabs({});
>        $('#date1').datepicker({...});
>        $('#foo3').resizable({...});
>        $('#foo4').accordion({...});
>     }
>
> });
>
> Have you tried
> new Function(code)();
> instead?
>
> cheers,
> - ricardo
>
> On Mar 26, 8:15 am, Gilles <[email protected]> wrote:
>
> > Hi,
>
> > I normally bebug my code myself, cos I believe it helps me improve
> > myself, but here I just can't figure it out.
>
> > basically I am writing a JQuery plugin, that JQuery plugin generate a
> > bit of code that I then eval later. The code is a casacde of getScript
> > with some initialization command being trigger in the middle (when all
> > the getScript are finished)
>
> > To make my life easy I thought I use $.globalEval(code) to make sure
> > it works accross all browsers. Like expected no issue with safari 3,
> > safari 4, FF2 or FF3 but as soon as i tried my test page on IE7
> > everything broke...
>
> > And of course I get the well know and very easy to debug error
> > 80020101.
>
> > 1. It's not because of comment (none used anywhere)
> > 2. I have tried:
>
> > eval(code)
> > eval(code,$)
> > window.eval(code)
> > execScript(code)
> > window.execScript(code)
> > window['code'] = code; window.eval(window['code'])
> > window['code'] = code; eval(window['code'])
> > window['code'] = code; window.execScript(window['code'])
> > window['code'] = code; execScript(window['code'])
> > and many other approach I fund during my search (window.eval || eval)
> > (code.... try {} catch {} etc....
>
> > (debugging IE so tried any stupid way I could think off too which
> > would explain some of the non-valid example above, I was desperate
> > lol)
>
> > 3. I have checked and checked the code I am trying to eval and I just
> > don't get it, I am pretty sure it's not a JQuery bug of course, but as
> > I am trying to do this via JQuery it give me an excuse to come and ask
> > the JQuery community and team where the best javascript developers
> > are! (kissing asses sometimes help :p)
>
> > Here is the code I am trying to eval:
>
> > Unformatted (I tried sending it using return carriage, compressed,
> > with space none of them works)
>
> > $.getScript('js/ui.core.js',function(){
> >         $.getScript('js/ui.dialog.js',function(){
> >                 $.getScript('js/ui.tabs.js',function(){
> >                         $.getScript('js/ui.datepicker.js',function(){
> >                                 $.getScript('js/ui.resizable.js',function(){
> >                                         
> > $.getScript('js/ui.accordion.js',function(){
> >                                                 $('#foo1').dialog({ 
> > bgiframe: true, height: 140, modal:
> > true });
> >                                                 $('#foo2').tabs({}); 
> > $('#date1').datepicker({altField: '#alt',
> > altFormat: 'DD, d MM, yy'});
> >                                                 $('#foo3').resizable({ 
> > maxHeight: 280, maxWidth: 440, minHeight:
> > 155, minWidth: 200 });
> >                                                 $('#foo4').accordion({ 
> > icons: { 'header': 'ui-icon-plus',
> > 'headerSelected': 'ui-icon-minus' } });
> >                                         });
> >                                 });
> >                         });
> >                 });
> >         });
>
> > });
>
> > 4. One last thing that is weird, also nothing and nothing at all
> > change sometimes it return an object doesn't support this property
> > error instead....
>
> > Here is the code building the code to eval:
>
> > // Start creating the code to be eval at the end ( we cascade
> > getScript)
> > for (i = 0; i < jsl; i++) code += '$.getScript(\''+file[i]+'.js
> > \',function(){';
>
> > // Add our init functions (we are inside the callback function of the
> > last getScript)
> > if (init.length > 0) code += init.join('; ')+';';
>
> > // Close all our getScripts
> > for (i = 0; i < jsl; i++) code += '});';
>
> > then just
>
> > $.globalEval(code);
>
> > to call it (used to test for ie, but got nothing that work with it, so
> > no real point until I can debug the issue.
>
> > If anyone can help please let me know I will really appreciate.
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" 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/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to