Shopify/batman — Issue #236: DOM node wrappers to provide easy access to batman.js behaviour.
Author: jamesmacaulay
Created: 2011-11-15 21:20:10+00:00
State: open
Labels: Feature

The `data-` attributes in the views are convenient for simple bindings, but become unwieldy when you want to do more complex things (like passing custom arguments to event handlers, for example). We should have a good interface for defining more involved logic in coffescript-land (either in the view or controller class).

Let's say we provide an accessor available on the controllers and views called `'nodes'`, whose only job is to expose nodes by their DOM id, like so:

```coffeescript
avatar = @get('nodes.currentUserAvatar')
```

This would return a wrapper around the DOM node with `id="currentUserAvatar"`. Then you might do something like this to bind its values from coffeescript:

```coffeescript
avatar.bind src: -> @get('currentUser').avatarURL()
avatar.route -> controller: 'users', action: 'show', id: @get('currentUser.id')
```
I'm just playing around with the interface here, the important thing is that we allow people to set up heavier logic in their coffeescript when things would otherwise get too clunky (or impossible) in the HTML.