hey all, i was required to create an auto complete drop down list, a common enough thing. i got it done soon enough, but decided i wanted to make a generic class so that i could attached this behavior to any number of elements that access different server side pages/behaviors. however, in my initialize method, i get the error: "event is not defined Event.observe(this.element, ''keyup'', this.elementKeyUpHandler(event));" the class is instantiated from another js file, which uses Event with no issue. i thought the problem could be some sort of class inheritance, but i am unsure how to inherit from from prototype, as it is an API not a class in it self. Then again i could be totally off, which i do suspect! any help would be great! here its the class snippet causing the problem: var AutoComplete = Class.create( { initialize: function(element) { this.blank = true; this.prevInput = ""; this.element = element; this.json = new Hash(); Event.observe(this.element, ''keyup'', this.elementKeyUpHandler(event)); Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); }, .... }); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Try replacing ... Event.observe(this.element, ''keyup'',this.elementKeyUpHandler(event)); Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); with this.element .observe(''keyup'', this.elementKeyUpHandler.bind(this)) .observe(''blur'', this.elementBlurHandler.bind(this)); Richard. On 21/11/2007, xzyfer <xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hey all, > > i was required to create an auto complete drop down list, a common > enough thing. > i got it done soon enough, but decided i wanted to make a generic > class so that i could attached this behavior to any number of elements > that access different server side pages/behaviors. > > however, in my initialize method, i get the error: > > "event is not defined > Event.observe(this.element, ''keyup'', > this.elementKeyUpHandler(event));" > > the class is instantiated from another js file, which uses Event with > no issue. > > i thought the problem could be some sort of class inheritance, but i > am unsure how to inherit from from prototype, as it is an API not a > class in it self. > Then again i could be totally off, which i do suspect! > > any help would be great! > > here its the class snippet causing the problem: > > var AutoComplete = Class.create( > { > initialize: function(element) > { > > this.blank = true; > this.prevInput = ""; > this.element = element; > this.json = new Hash(); > > Event.observe(this.element, ''keyup'', > this.elementKeyUpHandler(event)); > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > }, .... > }); > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry ... this.element .observe(''keyup'', this.elementKeyUpHandler.bindAsEventListener(this)) .observe(''blur'', this.elementBlurHandler.bindAsEventListener(this)); I''ve just been through an exercise of converting older procedural code to sleek new Prototype OO code. A base class and a specific class. With AJAX periodicupdater as a property of the class. The binding on this got VERY confusing. On 22/11/2007, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Try replacing ... > > Event.observe(this.element, ''keyup'',this.elementKeyUpHandler(event)); > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > with > > this.element > .observe(''keyup'', this.elementKeyUpHandler.bind(this)) > .observe(''blur'', this.elementBlurHandler.bind(this)); > > Richard. > > On 21/11/2007, xzyfer <xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hey all, > > > > i was required to create an auto complete drop down list, a common > > enough thing. > > i got it done soon enough, but decided i wanted to make a generic > > class so that i could attached this behavior to any number of elements > > that access different server side pages/behaviors. > > > > however, in my initialize method, i get the error: > > > > "event is not defined > > Event.observe(this.element, ''keyup'', > > this.elementKeyUpHandler(event));" > > > > the class is instantiated from another js file, which uses Event with > > no issue. > > > > i thought the problem could be some sort of class inheritance, but i > > am unsure how to inherit from from prototype, as it is an API not a > > class in it self. > > Then again i could be totally off, which i do suspect! > > > > any help would be great! > > > > here its the class snippet causing the problem: > > > > var AutoComplete = Class.create( > > { > > initialize: function(element) > > { > > > > this.blank = true; > > this.prevInput = ""; > > this.element = element; > > this.json = new Hash(); > > > > Event.observe(this.element, ''keyup'', > > this.elementKeyUpHandler(event)); > > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > > > }, .... > > }); > > > > > > > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
the problem i was having, was that along with the event, i was also trying to pass an argument to the elementKeyUpHandler, that was making things very difficult, because i could never seem to access the event, when i passes my own arguments, even if i specifically tried to pass event as one of the arguments. On 11/22/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > Sorry ... > > this.element > .observe(''keyup'', this.elementKeyUpHandler.bindAsEventListener(this)) > .observe(''blur'', this.elementBlurHandler.bindAsEventListener(this)); > > I''ve just been through an exercise of converting older procedural code > to sleek new Prototype OO code. A base class and a specific class. > With AJAX periodicupdater as a property of the class. The binding on > this got VERY confusing. > > On 22/11/2007, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > Try replacing ... > > > > Event.observe(this.element, ''keyup'',this.elementKeyUpHandler(event)); > > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > > > with > > > > this.element > > .observe(''keyup'', this.elementKeyUpHandler.bind(this)) > > .observe(''blur'', this.elementBlurHandler.bind(this)); > > > > Richard. > > > > On 21/11/2007, xzyfer <xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > hey all, > > > > > > i was required to create an auto complete drop down list, a common > > > enough thing. > > > i got it done soon enough, but decided i wanted to make a generic > > > class so that i could attached this behavior to any number of elements > > > that access different server side pages/behaviors. > > > > > > however, in my initialize method, i get the error: > > > > > > "event is not defined > > > Event.observe(this.element, ''keyup'', > > > this.elementKeyUpHandler(event));" > > > > > > the class is instantiated from another js file, which uses Event with > > > no issue. > > > > > > i thought the problem could be some sort of class inheritance, but i > > > am unsure how to inherit from from prototype, as it is an API not a > > > class in it self. > > > Then again i could be totally off, which i do suspect! > > > > > > any help would be great! > > > > > > here its the class snippet causing the problem: > > > > > > var AutoComplete = Class.create( > > > { > > > initialize: function(element) > > > { > > > > > > this.blank = true; > > > this.prevInput = ""; > > > this.element = element; > > > this.json = new Hash(); > > > > > > Event.observe(this.element, ''keyup'', > > > this.elementKeyUpHandler(event)); > > > Event.observe(this.element, ''blur'', > this.elementBlurHandler(event)); > > > > > > }, .... > > > }); > > > > > > > > > > > > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!" > > > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 22/11/2007, Michael Mifsud <xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> the problem i was having, was that along with the event, i was also trying > to pass an argument to the elementKeyUpHandler, that was making things very > difficult, because i could never seem to access the event, when i passes my > own arguments, even if i specifically tried to pass event as one of the > arguments.You can ... this.element .observe(''keyup'', this.elementKeyUpHandler.bindAsEventListener (this, ''Param1'', ''Param2'')) .observe(''blur'', this.elementBlurHandler.bindAsEventListener(this, ''Param1'', ''Param2'')); and elementKeyUpHandler : function(event, param1, param2) { ...}, elementBlurHandler : function(event, param1, param2) { ...},> > > On 11/22/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > Sorry ... > > > > this.element > > .observe(''keyup'', > this.elementKeyUpHandler.bindAsEventListener (this)) > > .observe(''blur'', > this.elementBlurHandler.bindAsEventListener(this)); > > > > I''ve just been through an exercise of converting older procedural code > > to sleek new Prototype OO code. A base class and a specific class. > > With AJAX periodicupdater as a property of the class. The binding on > > this got VERY confusing. > > > > On 22/11/2007, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Try replacing ... > > > > > > Event.observe(this.element, ''keyup'',this.elementKeyUpHandler(event)); > > > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > > > > > with > > > > > > this.element > > > .observe(''keyup'', this.elementKeyUpHandler.bind(this)) > > > .observe(''blur'', this.elementBlurHandler.bind(this)); > > > > > > Richard. > > > > > > On 21/11/2007, xzyfer < xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > hey all, > > > > > > > > i was required to create an auto complete drop down list, a common > > > > enough thing. > > > > i got it done soon enough, but decided i wanted to make a generic > > > > class so that i could attached this behavior to any number of elements > > > > that access different server side pages/behaviors. > > > > > > > > however, in my initialize method, i get the error: > > > > > > > > "event is not defined > > > > Event.observe(this.element, ''keyup'', > > > > this.elementKeyUpHandler (event));" > > > > > > > > the class is instantiated from another js file, which uses Event with > > > > no issue. > > > > > > > > i thought the problem could be some sort of class inheritance, but i > > > > am unsure how to inherit from from prototype, as it is an API not a > > > > class in it self. > > > > Then again i could be totally off, which i do suspect! > > > > > > > > any help would be great! > > > > > > > > here its the class snippet causing the problem: > > > > > > > > var AutoComplete = Class.create( > > > > { > > > > initialize: function(element) > > > > { > > > > > > > > this.blank = true; > > > > this.prevInput = ""; > > > > this.element = element; > > > > this.json = new Hash(); > > > > > > > > Event.observe(this.element, ''keyup'', > > > > this.elementKeyUpHandler(event)); > > > > Event.observe(this.element, ''blur'', > this.elementBlurHandler (event)); > > > > > > > > }, .... > > > > }); > > > > > > > > > > > > > > > > > > > -- > > > ----- > > > Richard Quadling > > > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > > "Standing on the shoulders of some very clever giants!" > > > > > > > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer : > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!" > > > > > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
that is beautiful, many thanks On 11/23/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > On 22/11/2007, Michael Mifsud <xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > the problem i was having, was that along with the event, i was also > trying > > to pass an argument to the elementKeyUpHandler, that was making things > very > > difficult, because i could never seem to access the event, when i passes > my > > own arguments, even if i specifically tried to pass event as one of the > > arguments. > > You can ... > > this.element > .observe(''keyup'', this.elementKeyUpHandler.bindAsEventListener (this, > ''Param1'', ''Param2'')) > .observe(''blur'', this.elementBlurHandler.bindAsEventListener(this, > ''Param1'', ''Param2'')); > > and > > elementKeyUpHandler : function(event, param1, param2) { ...}, > elementBlurHandler : function(event, param1, param2) { ...}, > > > > > > > On 11/22/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > > > Sorry ... > > > > > > this.element > > > .observe(''keyup'', > > this.elementKeyUpHandler.bindAsEventListener (this)) > > > .observe(''blur'', > > this.elementBlurHandler.bindAsEventListener(this)); > > > > > > I''ve just been through an exercise of converting older procedural code > > > to sleek new Prototype OO code. A base class and a specific class. > > > With AJAX periodicupdater as a property of the class. The binding on > > > this got VERY confusing. > > > > > > On 22/11/2007, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > Try replacing ... > > > > > > > > Event.observe(this.element, ''keyup'',this.elementKeyUpHandler > (event)); > > > > Event.observe(this.element, ''blur'', this.elementBlurHandler(event)); > > > > > > > > with > > > > > > > > this.element > > > > .observe(''keyup'', this.elementKeyUpHandler.bind(this)) > > > > .observe(''blur'', this.elementBlurHandler.bind(this)); > > > > > > > > Richard. > > > > > > > > On 21/11/2007, xzyfer < xzyfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > hey all, > > > > > > > > > > i was required to create an auto complete drop down list, a common > > > > > enough thing. > > > > > i got it done soon enough, but decided i wanted to make a generic > > > > > class so that i could attached this behavior to any number of > elements > > > > > that access different server side pages/behaviors. > > > > > > > > > > however, in my initialize method, i get the error: > > > > > > > > > > "event is not defined > > > > > Event.observe(this.element, ''keyup'', > > > > > this.elementKeyUpHandler (event));" > > > > > > > > > > the class is instantiated from another js file, which uses Event > with > > > > > no issue. > > > > > > > > > > i thought the problem could be some sort of class inheritance, but > i > > > > > am unsure how to inherit from from prototype, as it is an API not > a > > > > > class in it self. > > > > > Then again i could be totally off, which i do suspect! > > > > > > > > > > any help would be great! > > > > > > > > > > here its the class snippet causing the problem: > > > > > > > > > > var AutoComplete = Class.create( > > > > > { > > > > > initialize: function(element) > > > > > { > > > > > > > > > > this.blank = true; > > > > > this.prevInput = ""; > > > > > this.element = element; > > > > > this.json = new Hash(); > > > > > > > > > > Event.observe(this.element, ''keyup'', > > > > > this.elementKeyUpHandler(event)); > > > > > Event.observe(this.element, ''blur'', > > this.elementBlurHandler (event)); > > > > > > > > > > }, .... > > > > > }); > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > ----- > > > > Richard Quadling > > > > Zend Certified Engineer : > > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > > > "Standing on the shoulders of some very clever giants!" > > > > > > > > > > > > > -- > > > ----- > > > Richard Quadling > > > Zend Certified Engineer : > > http://zend.com/zce.php?c=ZEND002498&r=213474731 > > > "Standing on the shoulders of some very clever giants!" > > > > > > > > > > > > > > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---