Oops. I was wrong. I realize your event is on an element and not the class.

                       'keydown': function(event) {
                               if (event.code == 27) {
                                       this.displayBounceBox();
                               }
                       }.bind(this)

take a look at http://mootools.net/docs/Native/Event

On Mon, Feb 16, 2009 at 3:56 PM, nwhite <[email protected]> wrote:

> put:
>
> Implements : [ Events ],
>
> in the top of your class. Nice job so far.
>
> You might want to take a look at
> http://mootools.net/docs/Class/Class.Extras and consider using 'Options'
> as well. Much cleaner then extending like you have.
>
>
>
>
> On Mon, Feb 16, 2009 at 2:57 PM, Sheldon <[email protected]> wrote:
>
>>
>> Hi again.
>>
>> now my Event 'keydown' does not seam to be firing ?
>>
>> I have
>>
>>                $(this.options.actionId).addEvents({
>>                        'click': function(){
>>                                this.displayBounceBox();
>>                        }.bind(this),
>>                        'keydown': function() {
>>                                //console.log('key is pressed.. '+
>> window.code);
>>                                if (window.code == '27') {
>>                                        this.displayBounceBox();
>>                                }
>>                        }.bind(this)
>>                });
>>
>> Demo.
>> http://bouncebox.lendrum.co.nz/
>>
>> Javascript
>> http://bouncebox.lendrum.co.nz/assets/js/bounceBox-1-0.js
>>
>> On Feb 17, 8:29 am, Sheldon <[email protected]> wrote:
>> > Thanks Batman42
>> >
>> > Worked Perfectly !  Your a Champ !
>> >
>> > On Feb 17, 2:48 am, batman42ca <[email protected]> wrote:
>> >
>> > > Using this code as an example (you'll have the same problem on each
>> > > event:
>> >
>> > > $(this.options.closeId).addEvent('click', function(e){
>> > >       this.displayBounceBox();
>> > >  });
>> >
>> > > You need to change it to this:
>> >
>> > > $(this.options.closeId).addEvent('click', function(e){
>> > >       this.displayBounceBox();
>> >
>> > > }.bind(this));
>> >
>> > > Now the "this" inside your click event refers to the class in which
>> > > you declared your addEvent, rather than referring to the clicked
>> > > element.
>> >
>> > > On Feb 16, 12:55 am, Sheldon <[email protected]> wrote:
>> >
>> > > > Hi,  I am playing around writing fir first JS class and get an error
>> > > > when using 'this' on an Event.
>> >
>> > > > I get 'this.function_name() is not a function'  with firebug.  As I
>> > > > understand,  adding a 'click' event replaces 'this' with the
>> 'clicked'
>> > > > element propities,  so how do I call another funrtion from with in
>> my
>> > > > class?
>> >
>> > > > The function works fine on DOM_READY.
>> >
>> > > > Demo.http://bouncebox.lendrum.co.nz/
>> >
>> > > > Javascripthttp://bouncebox.lendrum.co.nz/assets/js/bounceBox-1-0.js
>> >
>> > > > ( Line 34 is where the Click Event is started. )
>>
>
>

Reply via email to