News for hackers. Stuff that matters.
Re:Your templating engine sucks and everything you've ever w... by Animus7 on Sunday December 11, 2011 @05:45AM (#3339814)
I've been doing exactly that in my more recent projects, and it works extremely well for simpler views/shallow DOMS.

But it turns into write-only code pretty fast when you have tons of callbacks flying around for highly interactive elements.

Re:Your templating engine sucks and everything you've ever w... by snprbob86 on Sunday December 11, 2011 @07:17PM (#3341612)
For one-off actions, like the "save" and "cancel" buttons, callbacks don't descend into madness. Most UIs have very few commands which need true event handling. And the ones that do, the commands are often pretty simple one-button -> one-command. Sometimes many-buttons -> parameterized-command.

For everything else, you can use data-binding. If you're already writing lexically scoped render functions, you can trivially create a data-bindable local object in a variable to eliminate the event management process. Instead of an onclick event for a checkbox, you can trivially set the checked property to be equal to an observable value box containing a boolean. With the right abstractions, callback spaghetti is not an issue.