News for hackers. Stuff that matters.
Re:Knockout: JS library for rich UIs, declarative bindings, ... by scotth on Wednesday October 20, 2010 @09:01AM (#1810991)
Very nice.

I'm disappointed to see JavaScript back in attributes though. Can the bindings be defined programmatically?

Re:Knockout: JS library for rich UIs, declarative bindings, ... by jashkenas on Wednesday October 20, 2010 @09:51AM (#1811177)
It's also calling eval() on every single data-bind attribute you have:

http://github.com/SteveSanderson/knockout/blob/master/src/bi...

Perhaps Steve can comment on how well this performs in real-world views with thousands of DOM elements...

Re:Knockout: JS library for rich UIs, declarative bindings, ... by stevensanderson on Wednesday October 20, 2010 @10:02AM (#1811218)
The evaling is a robust way to parse the JSON-like binding syntax at the full speed of the browser's native code. Much faster than implementing the parsing in JavaScript.
Re:Knockout: JS library for rich UIs, declarative bindings, ... by jashkenas on Wednesday October 20, 2010 @10:09AM (#1811242)
Just to be clear -- the "JSON-like binding syntax" includes arbitrary JavaScript code, right? That's how stuff like this works...

    <button data-bind="click: function() { allItems.sort() }, enable: allItems().length > 1">
      Sort
    </button>
Re:Knockout: JS library for rich UIs, declarative bindings, ... by stevensanderson on Wednesday October 20, 2010 @10:22AM (#1811292)
It can do in cases where you find that more convenient. Whenever you prefer to move logic into your view model and just reference it, you can do so. It's intended to be flexible.
Re:Knockout: JS library for rich UIs, declarative bindings, ... by stevensanderson on Wednesday October 20, 2010 @10:01AM (#1811213)
Think of the bindings as data, not as procedural code.

It's so much more convenient to do it this way (avoiding having to figure out where each bit of behaviour comes from), especially when you're generating UI from within templates.

Re:Knockout: JS library for rich UIs, declarative bindings, ... by ctb9 on Thursday October 21, 2010 @09:11AM (#1815216)
I'm only 4 hours into knockout.js but this seems to be the key benefit.

I've been massacring functions that manipulate multiple elements and instead am directly tying the behaviors to the underlying data. My future self is very pleased with me.