Skip to content

Instantly share code, notes, and snippets.

@rmurphey
Created December 7, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmurphey/4236349 to your computer and use it in GitHub Desktop.
Save rmurphey/4236349 to your computer and use it in GitHub Desktop.
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