3 ms·
I really appreciate this definition of "magical"... reminds me of some code I was reviewing that was something like this: HTML: <button class="does-stuff"
by taco_emoji 10y ago
I really appreciate this definition of "magical"... reminds me of some code I was reviewing that was something like this:
HTML:
<button class="does-stuff" id="foo">Foo</button>
<button class="does-stuff" id="bar">Bar</button>
<!-- etc -->
JS:
var handlers = {
fooClicked: function() { /* stuff */ },
barClicked: function() { /* stuff */ },
/* etc */
};
$('.does-stuff').each(function() {
$(this).click(handlers[this.id + "Clicked"]);
});
And like... OK, that's clever, but when I'm debugging the fooClicked() method 4 months from now, I can't just do a Find All for "fooClicked" and track down where it's being called from.