mikeric/rivets — pull request #114 by adjohnson916 (2013-01-05 08:03:00+00:00)
Title: multiple bindings

Added support for multiple bindings, with a basic test case.

While this isn't going to be useful for most binders, like "text", etc., since one binding will always fire last, it does open up some new possibilities.

It allowed me to develop a "classes" binder for the class attribute that pulls class names from one or more bindings, which is powerful than the built-in boolean "class-*" binder, as it lets the data determine the class names to use. The multiple binding support was the only clean way to do this, instead of a repeated "class" binding, since HTML doesn't allow multiple element attributes with the same name.

Here's the binder from the test case:

```javascript
rivets.binders.classes = function (el, value) {
var elClass = ' ' + el.className + ' ';
if (elClass.indexOf(' ' + value + ' ') === -1) {
el.className = el.className + ' ' + value;
}
else {
el.className = elClass.replace(' ' + value + ' ', ' ').trim();
}
};
```

And an example usage:
```html

```
```javascript
model = new Model({shape: 'square', color: 'red'}};
rivets.bind($('#model'), {model: model});
```
Results in:
```html

```