derickbailey/backbone.modelbinding — Issue #28: Format callback for bound HTML elements
Author: dswitzer
Created: 2011-10-11 16:35:20+00:00
State: open

I'd love to see a way to trigger a callback function for updating HTML elements (non-form elements.)

A couple of use cases:

* Applying a formatting mask to input
* Creating a mailto: link for an e-mail address

The simplest solution to implement would probably be to add another data-bind formatting option, so you could do:

```

```

The you'd then write your function like:

```
function formatEmail(element, value){
var $a = $("a").attr("href", "mailto:" + value).text(value).appendTo(element);
}
```

This would give you complete control over everything. I'd prefer a way to map a callback function directly within the view itself, so that all my JS logic is in one place, but this would probably be the easiest way to get something into the code.