Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hw#3 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Hw#3 #5

wants to merge 3 commits into from

Conversation

PeregudovN
Copy link

Пытался сделать самостоятельно. Но, все встало на передаче каких либо свойств из 1го класса в другой. Просто не понимаю что я не понимаю.....
Скопировал код из разбора ДЗ. И даже так все работает как то коряво и не правильно.

///////////////////////////////////////////////////////////////////////////////////////////////


//Все что смог сам реализовать. Не могу читать чужой код. Сразу становиться непонятно где что, кто что наследует и т.д.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В вашем коде главная проблема в том, откуда вы начали. Надо было начинать с определения класса корзины, попробовать получить товары корзины отрендерить их. Далее добавить обработчики на кнопки купить в каталоге и попробовать вызвать какой-нибудь метод карзины из них. Добавить метод добавления, подумать что ему должно приходить аргументом. Пробовать писать метод добавления и тд. То есть начать поэтапно реализовывать базовый функционал.
Сначала естественно будет непонятно - на это есть объяснения, ну и важно самостоятельно реализовывать, чтобы также формировать представление о том, что происходит, иначе чужой код вообще никак не понять.

rendered = false;

constructor(product, img = 'https://placehold.it/200x150') {
({ product_name: this.product_name, price: this.price, id_product: this.id } = product);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут должно быть id_product: this.id_product


render() {
this.rendered = true;
return `<div class="product-item">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у блока потерялся data-id

render(){
this.rendered = true;
return `<div class = "cart-item" data-id ="${this.id_product}">
<dic class ="product-bio">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опечатка dic -> div


_init() {
this.container.addEventListener('click',e =>{
if(e.target.classList.contains('.buy-btn')){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Класс лист содержит строки с названием классов без точек - точка это селектор css. Поэтому не будет сейчас работать, чтобы заработало должно быть e.target.classList.contains('buy-btn')

}
_init() {
this.container.addEventListener('click',e =>{
if(e.target.classList.contains('.del-btn')){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогичено кнопке купить - точку надо удалить

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants