title: Should Backbone.js grab GET parameters from URL?
body: <p>I am trying to implement a search function for my website. When the user types a search term <code>foobar</code> into a <code>input</code> box and submits it, he is redirected to <code>http://mydomain.com/search?query=foobar</code>.</p>
  
  <p><strong>Problem::</strong> How should I grab the GET parameters <code>query</code> from the URL, and send it to the backend and get a array of results back as a JSON response? Should I even do it this way?</p>
  
  <p>My current attempt below does not even cause the <code>search</code> function to be triggered.</p>
  
  <p><strong>Router</strong></p>
  
  <pre><code>var AppRouter = Backbone.Router.extend({
      routes: {
          'search?query=:query': 'search'
          // ... and some other routes
      },
  
      search: function(query) {
          this.photoList = new SearchCollection();
          var self = this;
          this.photoList.fetch({
              data: {query: query},
              success: function() {
                  self.photoListView = new PhotoListView({ collection: self.photoList });
                  self.photoListView.render();
              }
          });
      }
  
  });
  
  var app = new AppRouter();
  Backbone.history.start({
      pushState: true,
      root: '/'
  });
  </code></pre>