Shopify/batman — Issue #308: No way to reliably get DOM elements generated by bindings
Author: jlong64
Created: 2012-01-17 09:41:02+00:00
State: open

If you have a data-foreach binding to a batman set, then when adding objects to that set there is no way to reliably retrieve the DOM element created for that new object immediately after it's created. This prevents you from manipulating the new element right after it's added, which is useful for things like animation.

Here's an example event handler that illustrates the problem:

```coffeescript
addObject: (node, event) =>
@get("mySet").add new SomeObject
$(".some-object").last().slideDown()
```

This will slide down the second-to-last element because the new DOM element doesn't exist at the time you trigger the animation. At the moment, the workaround seems to be to put your animation behind a setTimeout with some arbitrary small time value, but that's pretty hacky and not guaranteed to work.

A potential solution could be to add a bindable event that gets triggered whenever an object is added, something like this:

```html

...

```