John,

While I'm glad to see a scope arg available, i still think this is negligent
to the future of jQuery and ES standards. I really think a fn.bind()
implementation would ideal (since it would be jQuery-wide and not just
available in one function), but as I've noted in the past and is exampled
here, beginners may find this syntax a bit boggling:

$(foo).bind('event', fn.bind(bar) );


Rick










On Sun, Dec 27, 2009 at 9:27 PM, Amina <aminad...@gmail.com> wrote:

> Thank you.
>
>
> On Dec 24, 7:11 am, Daniel Friesen <nadir.seen.f...@gmail.com> wrote:
> > Bad place for the scope.
> > This is what anonymous inline functions are for. There's also ES5's
> > fn.bind(this); which can be implemented in ES3 as a prototype. Your
> > example is also a little screwed up with it's use of document.
> > this.a = '1';
> > var that = this;
> > $(document).bind('scroll', function() { that.myScroll(); });
> >
> > or if you add a prototype to match ES5.
> > this.a = '1';
> > $(document).bind('scroll', this.myScroll.bind(this));
> >
> > ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
> >
> >
> >
> > Amina wrote:
> > > Cross-posted Jquery-group:
> >
> > > I am suggestion for new small feaute in jQuery.
> > > add a new proeprty to "bind" function. a Scope property.
> > > sometimes I am binding a function inside object. So I need a solution
> > > to change the scope of this function.
> > > something like:
> > >                 $().bind('click',data,scope,function)
> > > ----
> > > For Example:
> > > function myObj()
> > > {
> > > this.a='1'
> > > document.bind('scroll',this.myScroll);
> > > this.myScroll=function () {
> > >                 //Now I am trying to get this.a
> > >                 alert(this.a)}
> > >                 //This is make an error becuase this is an HtmlElement
> > > and not THIS
> > > object
> > > }
> >
> > > var a=new myObj();
> >
> > > One solution is to use the data property like:
> > > function myObj()
> > > {
> > > document.bind('scroll',this,this.myScroll);
> > > this.myScroll=function (data) {
> > >                 //Now I am trying to get this.a
> > >                 alert(data.a)}
> > > }
> >
> > > But I am sure that changing the scope will work better.
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups "jQuery Development" group.
> > > To post to this group, send email to jquery-...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com>
> .
> > > For more options, visit this group athttp://
> groups.google.com/group/jquery-dev?hl=en.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "jQuery Development" group.
> To post to this group, send email to jquery-...@googlegroups.com.
> To unsubscribe from this group, send email to
> jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/jquery-dev?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to