'use strict';

var router = require( '../router' );
var BaseView = require( './new-base-view' );

var WindowView = BaseView.extend({

  // Auto-wrapping of links with navigate method
  events: {
    'click a': 'navigate'
  },

  navigate: function( evt ) {
    var $el = this.$( evt.target );
    if ( ! $el.is( 'a' ) ) {
      $el = $el.closest( 'a' );
    }
    var targetUrl = $el.attr( 'href' );

    // Don't hijack any off-site links
    if ( /http/.test( targetUrl ) ) {
      return;
    }

    evt.preventDefault();

    router.nav( targetUrl );
  }

});

module.exports = new WindowView({
  el: document.body
});

'use strict';

var Backbone = require( 'backbone' );

var WindowView = Backbone.View.extend({
  el: 'body',

  // Auto-wrapping of links with navigate method
  events: {
    'click a': 'navigate'
  },

  navigate: function( evt ) {
    var $el = this.$( evt.target );
    if ( ! $el.is( 'a' ) ) {
      $el = $el.closest( 'a' );
    }
    var targetUrl = $el.attr( 'href' );

    // Don't hijack any off-site links
    if ( /http/.test( targetUrl ) ) {
      return;
    }

    evt.preventDefault();

    require( '../router' ).nav( targetUrl );
  }

});

module.exports = new WindowView();

--- 
+++ 
@@ -1,9 +1,9 @@
 'use strict';
 
-var Backbone = require( 'backbone' );
+var router = require( '../router' );
+var BaseView = require( './new-base-view' );
 
-var WindowView = Backbone.View.extend({
-  el: 'body',
+var WindowView = BaseView.extend({
 
   // Auto-wrapping of links with navigate method
   events: {
@@ -24,9 +24,11 @@
 
     evt.preventDefault();
 
-    require( '../router' ).nav( targetUrl );
+    router.nav( targetUrl );
   }
 
 });
 
-module.exports = new WindowView();
+module.exports = new WindowView({
+  el: document.body
+});
Convert WindowView to an ampersand-view

Uses the new base view to mix in jQuery functionality in the manner of
traditional backbone views
