This project is read-only.

Typescript and jQuery-Events

Topics: Code Checkins, General, Language Specification
Mar 14, 2014 at 8:13 AM
Edited Mar 14, 2014 at 8:14 AM
Hi all,

when I do this in my Typescript class:
    public Initialize(): void {
            axis: "y",
            scroll: false,
            containment: "window",
            stop: function (event, ui) {
                this.OnResize.trigger("stop", ui);
I receive the Event, but this doesn't point to the class instance it points to the jQuery object which is in this case a h3-Element.

How can I access the class members?

Best regards,
Mar 14, 2014 at 4:39 PM
How 'this' works is a bit different in JavaScript (and TypeScript by it being a superset). You probably need to turn the function pointed to by "stop:" to a lambda. You can read about this here: (scroll down to Lambdas and using 'this')

Another good reference is Yehuda Katz's blog post on 'this':
Marked as answer by NCC1701M on 3/16/2014 at 11:07 PM
Mar 17, 2014 at 7:07 AM

thanks for your help! :-)

Best regards,