// # Place all the behaviors and hooks related to the matching controller here.
// # All this logic will automatically be available in application.js.
// # You can use CoffeeScript in this file: http://coffeescript.org/

$(document).ready(function(){
  // bindSearchBySubmit();
  bindSearch();
})


var bindSearch = function(){
  $('form.navbar-form').on('click','submit, .glyphicon-search', function(event){
    event.preventDefault();
    var data = $("#peopleSearchBar").val();
    searchServer(data);
  })
}

var searchServer = function(data){
      $.ajax({
      url: 'search',
      method: 'post',
      dataType: 'html',
      data: {search_input: data}
    }).done(function(responseData){
      displayResults(responseData);
      unendorseListener();
    })
}

var displayResults = function(responseData){
  $('.tab-content').html(responseData)
}

// # Place all the behaviors and hooks related to the matching controller here.
// # All this logic will automatically be available in application.js.
// # You can use CoffeeScript in this file: http://coffeescript.org/

$(document).ready(function(){
  bindSearchBySubmit();
  bindSearchByButton();
})

var bindSearchBySubmit = function(){
  $('form.navbar-form').on('submit', function(event){
    event.preventDefault();
    var data = $("#peopleSearchBar").val();
    searchServer(data);
  })
}

var bindSearchByButton = function(){
  $('form.navbar-form').on('click','.glyphicon-search', function(event){
    event.preventDefault();
    var data = $("#peopleSearchBar").val();
    searchServer(data);
  })
}

var searchServer = function(data){
      $.ajax({
      url: 'search',
      method: 'post',
      dataType: 'html',
      data: {search_input: data}
    }).done(function(responseData){
      displayResults(responseData);
      unendorseListener();
    })
}

var displayResults = function(responseData){
  $('.tab-content').html(responseData)
}

--- 
+++ 
@@ -3,20 +3,13 @@
 // # You can use CoffeeScript in this file: http://coffeescript.org/
 
 $(document).ready(function(){
-  bindSearchBySubmit();
-  bindSearchByButton();
+  // bindSearchBySubmit();
+  bindSearch();
 })
 
-var bindSearchBySubmit = function(){
-  $('form.navbar-form').on('submit', function(event){
-    event.preventDefault();
-    var data = $("#peopleSearchBar").val();
-    searchServer(data);
-  })
-}
 
-var bindSearchByButton = function(){
-  $('form.navbar-form').on('click','.glyphicon-search', function(event){
+var bindSearch = function(){
+  $('form.navbar-form').on('click','submit, .glyphicon-search', function(event){
     event.preventDefault();
     var data = $("#peopleSearchBar").val();
     searchServer(data);
Refactor two listeners into one
