Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
Permalink
Newer
Older
100644 25 lines (22 sloc) 525 Bytes
December 7, 2012 23:11
1
// IMPL
2
define([ 'jquery' ], function( $ ) {
3
var SearchData = function( opts ) {
4
if ( !(this instanceof SearchData) ) {
5
return new SearchData( opts );
6
}
7
};
8
9
SearchData.prototype.fetch = function( query ) {
10
if ( !query ) {
11
var dfd = $.Deferred();
12
dfd.resolve( [] );
13
return dfd.promise();
14
}
15
16
return $.ajax( '/data/search.json', {
17
data : { q: query },
18
dataType : 'json'
19
}).pipe(function( resp ) {
20
return resp.results;
21
});
22
};
23
24
return SearchData;
25
});