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
// 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', |
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
// Fake "moving forward" to a new URL | |
History.pushState({main:$("#main").html(), search_term:search_term}, '', search_url); |
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
// application.js | |
function youtubeResults() { | |
var youtube_url = $("#youtube_url").text(); | |
... |
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
# 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 |
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
if request.xhr? | |
render "search", layout: false | |
else | |
render :index | |
end |
NewerOlder