S
S
Stepan2015-10-24 11:39:22
JavaScript
Stepan, 2015-10-24 11:39:22

How to correctly pass changes on click to another class?

There are 2 different classes, how to connect them correctly, in one, onclick should occur, and in the other, the reaction to these changes.
Without using jQ

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-10-24
@IonDen

Through events. For example in jQuery:

// класс1
$some.on('click', function () {
    $(document).trigger('custom_event', data);
});

// в классе 2 подписываемся на это событие
$(document).on('custom_event', function (data) {
    // выполняем наш код, после события в классе 1
});

UDP: You can repeat it on pure JS: habrahabr.ru/post/229189
In react, too, through events, only if you use Flux, events should fly through the dispatcher. Google flux.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question