documentcloud / visualsearch

A Rich Search Box for Real Data
http://documentcloud.github.io/visualsearch/
MIT License
1.8k stars 225 forks source link

Pluggable SearchFacet views #51

Closed masklinn closed 12 years ago

masklinn commented 12 years ago

Currently, VisualSearch will always instantiate a VS.ui.SearchFacet when rendering a facet model.

On a project I'm working on, I need some facets (inserted programmatically, see pull request 49) to have slightly special renderings or behaviors.

To that end, I simply added a make_facet callback option which defaults to VS.ui.SearchFacet and should return some sort of VS.ui.SearchFacet-like backbone view. Because JS constructors will use an explicitly returned value if any, make_facet can be a simple function as long as all code paths return a view instance.

samuelclay commented 12 years ago

I don't think this fits with any sizable use cases, but it's a fine change to make on a fork. Considering it's such a minor code change, a fork would be just as easy to pull from. But I only see this adding complexity, and if you're already custom rendering at this stage beyond what the callbacks and events provide, then you will likely have to do some serious heroics anyhow.