okfn/facetview — pull request #13 by tomoinn (2012-08-09 11:29:03+00:00)
Title: Add custom renderer plugability

I've added a new option 'renderer' to the facetview code, if present this overrides the result presentation configured elsewhere apart from the wrapping table which is generated as usual. It causes each hit to be rendered in its own table row with a single td, and passes the jQuery wrapped TD and the object representing the search hit (the underlying data and not the actual hit object) to the function passed in as 'renderer', i.e. you can do:

```javascript
$('#facetText').facetview({
search_url : '/api/texts-es?',
search_index : 'elasticsearch',
facets : [ {
'field' : 'author.name',
'display' : 'author'
}, {
'field' : 'year',
'display' : 'year'
} ],
renderer : function(hit, parent) {
parent.append("

Title : " + hit.title + "

");
if (hit.textus && hit.textus.textId) {
parent.append("Read");
}
}
});
```