Skip to content

Instantly share code, notes, and snippets.

// In our DOM ready
var poets = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit:10,
prefetch: {
// url points to a json file that contains an array of author names
// e.g. ['Baudelaire', 'Beckett']
url: './poets.json',
// Fake "moving forward" to a new URL
History.pushState({main:$("#main").html(), search_term:search_term}, '', search_url);
// application.js
function youtubeResults() {
var youtube_url = $("#youtube_url").text();
...
# home_controller.rb
if request.xhr?
search = params[:search]
numberYouTube = '10'
@youtube_url = 'http://gdata.youtube.com/feeds/api/videos?q='+search.inspect+'&format=5&max- results='+numberYouTube+'&v=2&alt=jsonc'
render "search", layout: false
if request.xhr?
render "search", layout: false
else
render :index
end