Reputation: 32798
I have the following typescript code:
export class Modal {
private link: Link;
constructor (public $link: JQuery) {
this.link = new Link($link);
this.ajaxGet(this.link);
}
ajaxGet(link: Link) {
$.ajax(link.Href,
{
context: {
link: link
},
dataType: 'html'
})
.done(this.ajaxDone)
.fail(this.ajaxFail);
}
ajaxDone(data: string, textStatus: string, jqXHR: JQueryXHR) {
var link = <Link> this.link;
link.Modal.Content = data;
this.create(link);
}
create(link: Link) {
var a = link;
}
}
This works up to the point where in the ajaxDone I have a this.create(link). The problem is that the "this" is no longer the Modal and it has no create function. How can I get it to call the Modal.Create() function at this point?
Upvotes: 1
Views: 132
Reputation: 250922
I think your context is wrong in your Ajax call - the context is...
This object will be made the context of all Ajax-related callbacks
http://api.jquery.com/jQuery.ajax/
$.ajax(this.link.Href, {
context: this,
dataType: 'html'
})
.done(this.ajaxDone)
.fail(this.ajaxFail);
Upvotes: 2