[Dojo-interest] Accessing dojoAttachPoints from nested function literals

Andrew Scott andrew.scott at aegeon.com.au
Fri Nov 10 05:38:01 MST 2006


hey cliff thats is a nice trick, i was wondering how that was done.

On 11/10/06, Cliff Zhao <zhaotq at gmail.com> wrote:
>
> When the function is executed, the "this" is your x (instance of
> dojo.io.FormBind) which does not have the property ResultBox.
>
> What you should do is:
>   x.onSubmit = dojo.lang.hitch(this, function(){
>      this.ResultBox.innerHTML = "IT DOESN'T WORK HERE";
>      return false;
>    });
>
>
>
>  On 11/9/06, Nicholas Retallack < nickretallack at gmail.com> wrote:
> >
> > I've found I can't access nodes assigned with dojoAttachPoint in
> > function literals that are nested beyond one layer under defineWidget.
> > Is there any convenient way to get this data through?
> >
> > Here's an example of how my code works, with irrelevant stuff replaced
> > by ...s.
> > dojo.widget.defineWidget( ...,...,
> > { ...,
> >   fillInTemplate: function(){
> >     this.ResultBox.innerHTML = "IT WORKS HERE";
> >     var x = new dojo.io.FormBind(...)
> >     x.onSubmit = function(){
> >        this.ResultBox.innerHTML = "IT DOESN'T WORK HERE";
> >       return false;
> >     }
> >   }
> > });
> >
> > The ResultBox gets filled by the first call to it, but when you click
> > the submit button dojo prints an error about how " this.ResultBox has
> > no properties".  What should I do to make this field accessible to the
> > nested function?  Do I need to use a javascript wrapping technique, or
> > is there a nicer dojo way to handle this?
> > _______________________________________________
> > Dojo FAQ: http://dojo.jot.com/FAQ
> > Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
>
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> 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/20061110/253e1797/attachment-0001.html


More information about the Dojo-interest mailing list