4 ms·
Patiently waiting until the pendulum swings back to async binding js events to elements by classes and ids and any inlining gets frowned upon.
by kh_hk 3y ago
Patiently waiting until the pendulum swings back to async binding js events to elements by classes and ids and any inlining gets frowned upon.
- tipiirai 3y agoNot sure what you mean. Can you provide some sample code so I can undesrstand the issue / use-case?
- kh_hk 3y agoNot sure why but separation of concers was hammered so hard for a while that I cannot accept any inlined javascript or css at all. For me the reason is clear, I do not need to scan the html to know what a particular piece of code is doing and will just assume these ids are somewhere out there. The first example of the site would become: <div> <h2>You clicked {count} times!</h2> <button id='decrement'>Decrement</button> <button id='increment'>Increment</button> <script> count = 0 $('button#increment').on('click', () => { count++ }) $('button#decrement').on('click', () => { count-- }) </script> </div>
- meiraleal 3y agoA bit more magic to need a new framework: <div> <h2>You clicked {count} times!</h2> <button id='decrement'>Decrement</button> <button id='increment'>Increment</button> </div> <script> count = 0 increment.click(() => { count++ }) decrement.click(() => { count-- }) </script>
- tipiirai 3y agoGlad to hear people still care about separation of concerns! It's been so untrendy. Particularly after Tailwind came around.