Reputation: 37909
I have this bit of code which works.
I now want to use it in a typescript app. I still want to use jquery, but I don't understand how to convert the use of this
to what Typescript needs to work.
if ($(this).width() < 769) {
$('body').addClass('page-small');
} else {
$('body').removeClass('page-small');
$('body').removeClass('show-sidebar');
}
In typescript, this
refers to the current class. What do I replace that with so it works as expected?
Upvotes: 0
Views: 743
Reputation: 275947
I still want to use jquery, but I don't understand how to convert the use of this to what Typescript needs to work.
Move the function out of the class and call it from the class. Alternatively create a self
variable to use both this
(class) and this
(jquery).
Upvotes: 1