Answer the question
In order to leave comments, you need to log in
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
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.
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 questionAsk a Question
731 491 924 answers to any question