documentcloud / visualsearch

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

Problem with Backbone master after 1.0.0 #112

Closed josx closed 10 years ago

josx commented 11 years ago

Hi! I am trying to use VisualSearch.js with Backbone 1.0.0 version. Is that posible?

My code just make an Init, no more and I am getting this Uncaught TypeError: Cannot read property 'app' of undefined on

VS.ui.SearchBox = Backbone.View.extend({

  id  : 'search',

  events : {
    'click .VS-cancel-search-box' : 'clearSearch',
    'mousedown .VS-search-box'    : 'maybeFocusSearch',
    'dblclick .VS-search-box'     : 'highlightSearch',
    'click .VS-search-box'        : 'maybeTripleClick'
  },

  // Creating a new SearchBox registers handlers for re-rendering facets when necessary,
  // as well as handling typing when a facet is selected.
  initialize : function() {
    this.app = this.options.app;
josx commented 11 years ago

Sorry But breaks with master branch on Backbone, at least with this as latest commit: https://github.com/jashkenas/backbone/commit/517624db111cbf3e392a73ae91e590a0cd73c77d

josx commented 11 years ago

After researching a little I found a change on view's options. You can check it out on https://github.com/jashkenas/backbone/pull/2461 So for VS to work we need to add to views:

...
initialize : function(options) { 
    this.options = options;
...
knowtheory commented 11 years ago

Yep, happy to take a PR if you'd like to submit one!

josx commented 11 years ago

Ok no problem I will do it tomorrow

josx commented 11 years ago

@knowtheory If you have time take a look on it ;)