On 22/11/2007, Michael Mifsud <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 < [EMAIL PROTECTED]> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to