[Dojo-interest] Re: ContentPane executing scrpts

Jeoff Wilks jeoffwilks at gmail.com
Tue Apr 18 08:14:21 MDT 2006


It seems to me Fredrik's example is equivalent to just having ContentPane
write the eval'd script object into the global scope... which, in my
opinion, is a perfectly good idea.

That way you leave it up to the programmer whether they want to define their
functions inside a scope object or not. If they define the functions
globally then yes, those definitions may overwrite other functions; but
that's the way it always is in Javascript, even when the browser is
evaluating script. You define your functions inside a scope object, or you
take the risk of collisions.



On 4/16/06, Bill Keese <bill at dojotoolkit.org> wrote:
>
> Wow, I never expected ContentPane to be this powerful, but maybe it's a
> good idea.
>
> > <script>
> >       var execScope = {};
> >       execScope.clickMe = function(){
> >               dojo.debug("You clicked me!");
> >       }
> >
> >       execScope.myVar = "fubar";
> > </script>
> > <a href="javascript:alert(execScope.myvar);execScope.clikMe();"
> >click</a>
> >
> > the ContentPane parse code could then relative easy find all the inline
> > execCode parts in html attributes and replace them with the widget
> scope, and
> > the exec code of contentPane could then point the the code as part
> of  of the
> > widget scope so you could access it from the outside:
> >
> > var scope = dojo.widget.byId("Pane1").execScope;
> > scope.myVar = "no fubar";
>
>
> That seems reasonable to me, at least on first glance.  Have a special
> keyword in downloaded pages, so that ContentPane can do substitutions
> (and cleanup) easily.
>
> Bill
>
> Fredrik Johansson wrote:
> > onsdag 12 april 2006 18:08 skrev Jon Sykes:
> >
> > Hi Jon!
> > Thanks for the reply!
> > I've been thinking about this during work today
> >
> >> Maybe JS loaded by a contentPane, and all triggers (inline or not)
> >> associated with that loaded content should be given a unique namespace.
> >>
> >> Like maybe the widget name of that pane.
> >
> > Yeah, or a maybe a specifik property to contentpane so we dont pollut
> the
> > global namespace, say for example execScope.
> >
> >> That way two pages loading the same function woudl end up with:
> >
> > Just so we mean the same thing, the script below souldnt get fixed to
> this
> > state, instead the script author would have to write it this way, right?
> >
> > I mean the possibilities of doing errors during parse fix are endless,
> imagine
> >
> > <a href="" onblur="myblurfunction();"
> > or
> > <a href="javascript:func1(); func2(); document.write();"
> > or
> > <a href="javascript:dojo.debug(myglobalvar)"..
> >
> > trying to fix this mess during parse isnt realistic, at least not in my
> view,
> > and that is just the eventhandlers, trying to fix the code is even
> worse.
> >
> > var myglobalvar = "blah";
> > or
> > dojo.inherits(class1, dojo.widget.HtmlWidget);
> > or
> > function func1(){
> >       dojo.widget.HtmlWidget.call(this);
> > }
> >> Pane1 content pane:
> >>
> >> JS:
> >>
> >> function pane1.clickme(){
> >> //blah
> >> }
> >>
> >> <a href="javascript:pane1.clickme();">Click Me</a>
> >>
> >>
> >>
> >> Pane2 content pane:
> >>
> >> JS:
> >>
> >> function pane2.clickme(){
> >> //blah
> >> }
> >>
> >> <a href="javascript:pane2.clickme();">Click Me</a>
> >>
> >>
> >> Not sure how you'd implement that though, but it might solve the issue.
> >
> > so a page retrieved by contentpane could look something like:
> >
> > <script>
> >       var execScope = {};
> >       execScope.clickMe = function(){
> >               dojo.debug("You clicked me!");
> >       }
> >
> >       execScope.myVar = "fubar";
> > </script>
> > <a href="javascript:alert(execScope.myvar);execScope.clikMe();"
> >click</a>
> >
> > the ContentPane parse code could then relative easy find all the inline
> > execCode parts in html attributes and replace them with the widget
> scope, and
> > the exec code of contentPane could then point the the code as part
> of  of the
> > widget scope so you could access it from the outside:
> >
> > var scope = dojo.widget.byId("Pane1").execScope;
> > scope.myVar = "no fubar";
> >
> >>
> >> Jon Sykes
> >>
> >> On Apr 12, 2006, at 12:02 PM, Fredrik Johansson wrote:
> >>> If we go with 1. it will break when you have 2 contentpanes pulling
> >>> 2 separate
> >>> functions with the same name.
> >
> > Just some thoughts (and if they are unreadable its because I'm so tired
> > tonight, my apologies)
> >
> > Regards
> > Fredrik Johansson
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
> --
>
> Bill
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20060418/98b78615/attachment.html


More information about the Dojo-interest mailing list