I need to remove some popup element from the page with a click on the button, but something is happening to the context or to the property of the object and I have absolutely no idea what is going on.
constructor(container) {
this._container = container;
this._card = null;
this._popup = null;
}
render(card) {
this._card = new Card(card);
renderComponent(this._container, this._card);
this._card.clickCardListener(".film-card__title", "click", function () {
this._popup = new Popup(card);
console.log(this._popup);
**//log: Popup {_element: null, _card {...}**
renderComponent(mainElement, this._popup);
console.log(this._popup);
**//log: Popup {_element: section.film-details, _card {...}**
this._popup
.getElement()
.querySelector(".film-details__close-btn")
.addEventListener("click", function () {
console.log(this._popup);
**//log: undefined**
});
});
}
All this worked before I've tried to use a controller (I am studying OOP, so it goes...) Please, help. I've already spent about 5 hours on this line code and i have no idea what am i doing