marionettejs/backbone.marionette — pull request #389 by dgbeck (2012-12-15 07:06:29+00:00)
Title: Three small features for the ui + events hashes

I was going to try to submit this as three different pull requests because there are really three different changes here, but I am still learning git and I think I am too far down a wrong path, so I will just submit these three changes as one pull request. Here are the three changes:

1. Support for the ui element being a function. This allows a class to extend the ui element of its parent. For example:
```javascript
ui : function() { return _.extend( {}, baseFieldView.prototype.ui, {
"valueFld" : "[name='value']"
} ); },
```

2. Support for using the "aliases" setup by the ui element in the "events" hash. For example:

```javascript
ui : {
"valueFld" : "[name='value']"
},

events : {
"focus valueFld" : "_saveOldValue"
}
```

3. Support for automatically asserting that selectors in the ui hash select one and only one DOM element. Often times I find that my selectors either do not select what I anticipate from the get-go, or more illusively, something changes and the selector no longer maps correctly to the DOM. Sometimes it is difficult to track down errors caused by these cases, but this difficultly can be avoided by asserting that your selectors are actually selecting something (and not too many things). This implementation uses an explanation mark at the end of the selector to indicate that it should select one and only one DOM element. So, for example,
```javascript
ui : {
"valueFld" : "[name='value']!"
},
```
In this case, if `this.$( "[name='value']" ).length` is anything but 1, an error is thrown from `view#bindUIElements`:

Expected "[name='value']" to match 1 element, but 0 found.