Created
June 4, 2012 15:38
-
-
Save ornerymoose/2869105 to your computer and use it in GitHub Desktop.
How to go about adding an image to the autocomplete, but more importantly returning an array of objects than an array of strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for :javascripts do | |
- cache('search_autocomplete') do | |
:javascript | |
$(function(){ | |
var products = JSON.parse#{auto_complete_products}; | |
$("#keywords").autocomplete(products,{ | |
appendToElement: ".autocomplete" | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- content_for :javascripts do | |
- cache('search_autocomplete') do | |
:javascript | |
$(function(){ | |
var products = JSON.parse#{auto_complete_products}; | |
$("#keywords").autocomplete(products,{ | |
appendToElement: ".autocomplete" | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auto_complete_products | |
product_names = Product.select('distinct products.name').active.on_hand.map(&:name) | |
merchant_names = Couponcodes::Merchant.select("distinct store_name").active.by_store_name.map(&:store_name) | |
(product_names + merchant_names).uniq.sort | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment