Search with underscore and jQuery

Super simple array filtering with _.js and jQuery.

// up to you to get this from somewhere = [
  "Apples growing guide",
  "Orange growing",
  "Apple repair guide",
  "ruby on rails setup guide",
  "ruby vps install",
  "rails to sinatra"

$("input.omnibar").on('keyup', function(e){
  // clear our results list
  var $ul = $("ul.omnibar_results").html("");
  if($(this).val() == ""){
    // dont show anything if the query is empty
  // get our query, remove excess white space, down case 
  // and split on white space
  var query = $(this).val().trim().toLowerCase().split(/[^\w]/);
  var results =, function(d){
    return _.all(query, function(q){
      return d.toLowerCase().match(q);
  }), function(r){
  }, $ul);

Written 26th of August, 2012