S
S
sorry_i_noob2018-04-12 20:48:29
Layout
sorry_i_noob, 2018-04-12 20:48:29

Why add "js" classes when laying out? I understand - separation of representation and logic. But why is this necessary? Why is this division necessary?

Well, for example, I have such a selector: #filter-date__input-from. Why is it bad that I will hang the handler on it, and not on .js-filter-date__input-from?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dom1n1k, 2018-04-12
@sorry_i_noob

It often happens that the visual part of the front is done by one person, and the "animation" by another. And then a few others. So that they overlap as little as possible.

A
Alexey Sklyarov, 2018-04-12
@0example

The bad thing is that you have 5 different buttons but they all fire the same event. Will you use the same handler for 5 different IDs? Or do you still create one class, write only a handler for it, and write this class for all buttons that you want to assign some action to? I think the answer is obvious. And classes like .js-add-to-cart are made in order to make it easier to find your functionality in the code, because it’s immediately clear that some kind of handler is hung here than trying to look for a potential ID in your js code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question