documentcloud / visualsearch

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

Callbacks #128

Closed josx closed 10 years ago

josx commented 10 years ago

Just add as default callback clearSearch (for noticing anyone that it is there). Also adding callback for use when individual facet is removed.

samuelclay commented 10 years ago

I accepted the PR, but why bother binding to the removeFacets event? By removing a facet, a search event is triggered. Wouldn't that be better to watch, since you can just remain stateless and search on the new query.

samuelclay commented 10 years ago

As you can see with the comment above the search box's removedFacet method, I write:

// When removing a facet, potentially do something. For now, the adjacent
// remaining facet is selected, but this is handled by the facet's view,
// since its position is unknown by the time the collection triggers this
// remove callback.
removedFacet : function (facet, query, options) { ... }

So you're not going to have a reference to what was just deleted, so why not just listen to the search event?