define(['jquery', 'jquery.typeahead', 'backbone'], function($, ignore, Backbone) {

  var NodeSearch = Backbone.View.extend({

    render: function() {
      
      var graphModel = this.options.graphModel;
      var dataProvider = this.options.dataProvider;

      var $container = $("<div />").addClass("node-search-container");
      var $input = $('<input type="text" placeholder="Node Search...">').addClass("node-search-input");
      $container.append($input);
      this.$el.append($container);

      $input.typeahead({
        prefetch: dataProvider.getNodesPath(),
        name: "nodes",
        limit: 100,
      }).on("typeahead:selected", function(e, datum) {
        var newNode = {text: datum.value};
        var h = graphModel.get("nodeHash");
        var newNodeHash = h(newNode);
        if (!_.some(graphModel.get("nodes"), function(node) {
          h(node) === newNodeHash;
        })) {
          graphModel.putNode(newNode);
        }
        $(this).blur();
      });

      return this;

    },

  });

  return NodeSearch;

});
@@ -128,83 +128,102 @@
     
-render: function() %7B%0A      %0A      var graphModel = this.options.graphModel;
+events: %7B%0A      'typeahead:selected input': %22addNode%22,%0A    %7D,%0A%0A    render: function() %7B%0A      
 %0A   
@@ -643,57 +643,121 @@
   %7D)
-.on(%22typeahead:selected%22, function(e, datum) %7B%0A  
+;%0A%0A      return this;%0A%0A    %7D,%0A%0A    addNode: function(e, datum) %7B%0A      var graphModel = this.options.graphModel;%0A
     
@@ -793,18 +793,16 @@
 value%7D;%0A
-  
       va
@@ -837,26 +837,24 @@
 sh%22);%0A      
- 
- 
 var newNodeH
@@ -867,26 +867,24 @@
 h(newNode);%0A
-  
       if (!_
@@ -927,26 +927,24 @@
 ion(node) %7B%0A
-  
         h(no
@@ -974,18 +974,14 @@
     
-  
 %7D)) %7B%0A
-  
     
@@ -1023,22 +1023,18 @@
     
-  %7D%0A  
+%7D%0A
       $(
 this
@@ -1029,20 +1029,24 @@
       $(
-this
+e.target
 ).blur()
@@ -1051,39 +1051,8 @@
 ();%0A
-      %7D);%0A%0A      return this;%0A%0A
     

use backbone view events in nodeSearch