
$(function() {
    function log(message) {
        $("<div/>").text(message).prependTo("#log");
        $("#log").attr("scrollTop", 0);
    }
    
    $("#searchbox").autocomplete({
        source: "/issue/xhr_search/",
        minLength: 2,
        select: function(event, ui) {
            log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
        }
    });
    $("#search_user").autocomplete({
        source: "/profile/xhr_search/",
        minLength: 2,
        select: function(event, ui) {
            log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
        }
    });

});


@@ -140,16 +140,28 @@
   %7D%0A
+%0A
     
-%0A   
+var searchbox =
  $(%22
@@ -172,16 +172,66 @@
 rchbox%22)
+;%0A%0A    if(searchbox.length)%7B    %0A        searchbox
 .autocom
@@ -230,32 +230,36 @@
 .autocomplete(%7B%0A
+    
         source: 
@@ -280,32 +280,36 @@
 arch/%22,%0A        
+    
 minLength: 2,%0A  
@@ -306,32 +306,36 @@
 gth: 2,%0A        
+ 
+   
 select: function
@@ -340,32 +340,36 @@
 on(event, ui) %7B%0A
+    
             log(
@@ -480,34 +480,42 @@
 value);%0A        
-%7D%0A
+    %7D%0A    
     %7D);%0A    $(%22#
@@ -509,20 +509,46 @@
  %7D);%0A   
+ %7D;%0A%0A    var search_user =
  $(
-%22
+'
 #search_
@@ -551,18 +551,68 @@
 rch_user
-%22)
+');%0A%0A    if(search_user.length)%7B%0A        search_user
 .autocom
@@ -611,32 +611,36 @@
 .autocomplete(%7B%0A
+    
         source: 
@@ -663,32 +663,36 @@
 arch/%22,%0A        
+ 
+   
 minLength: 2,%0A  
@@ -681,32 +681,36 @@
   minLength: 2,%0A
+    
         select: 
@@ -723,32 +723,36 @@
 on(event, ui) %7B%0A
+    
             log(
@@ -875,18 +875,32 @@
     
-%7D%0A
+    %7D%0A   
     
+ 
 %7D);%0A
+    %7D;
 %0A%7D);

make search js not crash on absence of searchbox id