The upcoming jQuery 1.4 already has: .bind("click", fn, scope)
--John On Wed, Dec 23, 2009 at 10:06 AM, Amina <aminad...@gmail.com> 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. > 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.