Created
December 7, 2012 20:44
-
-
Save rmurphey/4236349 to your computer and use it in GitHub Desktop.
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
define([ | |
'jquery', | |
'underscore', | |
'util', | |
'searchForm', | |
'searchResults', | |
'data' | |
], function( $, _, util, SearchForm, SearchResults, SearchData ) { | |
$(function() { | |
var liked = $( '#liked' ); | |
var pending = false; | |
var searchForm = new SearchForm( $('#searchForm') ); | |
var searchResults = new SearchResults( $('#results') ); | |
var searchData = new SearchData(); | |
searchForm.on( 'search', function( event ) { | |
if ( pending ) { return; } | |
var query = event.detail; | |
pending = true; | |
searchData.fetch( query ).then(function( results ) { | |
searchResults.setResults( results ); | |
pending = false; | |
}); | |
searchResults.pending(); | |
}); | |
searchResults.on( 'like', function( evt ) { | |
var name = evt.detail; | |
liked.find( '.no-results' ).remove(); | |
$( '<li>', { text: name } ).appendTo( liked ); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment