gazes12
@gazes12

Почему не получается получить возвращаемый массив?

Здравствуйте.

Вот код:

const applyUpdateds = $('.change-recall__buttons-send');

function changeComment(data){
    console.count('changed');

    create_form.removeClass('visible');
    change_form.addClass('visible');

    const _this = data;
    const _thisId = _this.attr('id');

    change_id.html('id: ' + _thisId) /*_thisId получается*/;

    return [_this, _thisId];
}

applyUpdateds.click((e) =>{
    e.preventDefault();

    const {_this, _thisId}  = changeComment();
    console.count(`applied ${_this}, ${_thisId}`);
});


$(document).on('click', '.recall__people-buttons-change', function(){
    changeComment($(this));
});


Выводит ошибку: Uncaught TypeError: Cannot read properties of undefined (reading 'attr'), на эту строчку кода: const _thisId = _this.attr('id');
При этом выводится changed: 2 (функция changeComment выполняется второй раз).

Помогите пожалуйста решить проблему :)
  • Вопрос задан
  • 88 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы