import $ from 'jquery';
import * as Backbone from 'backbone';
import dispatcher from '../helpers/dispatcher';

class SearchBoxView extends Backbone.View {

  get el() { return '#search-box'; }

  get events() {
    return {
      'submit form': 'getQuery'
    }
  }

  initialize() {
    window.console.log('SearchBoxView initialized!');
  }

  getQuery() {
    let query = $('#search-box input').val();
    if( query !== '' ) {
      dispatcher.trigger('router:go', 'search/?q=' + query);
    }
  }

}

export default SearchBoxView;

import $ from 'jquery';
import * as Backbone from 'backbone';
import dispatcher from '../helpers/dispatcher';

class SearchBoxView extends Backbone.View {

  get el() { return '#search-box'; }

  get events() {
    return {
      'submit form': 'sendQuery'
    }
  }

  get query() {
    return $('#search-box input').val();
  }

  initialize() {
    window.console.log('SearchBoxView initialized!');
  }

  sendQuery() {
    if( this.query !== '' ) {
      dispatcher.trigger('router:go', ('search/?q=' + this.query));
    }
  }

}

export default SearchBoxView;

Rename functions in SearchBox View
Rename functions in SearchBox View

* improves clarity
* use getter to grab string from text box
* rename function that triggers search: get -> send
