Slide 35
Slide 35 text
searchForm.on('search', update);
function update(t) {
var term = $.trim(t),
existing = searches.where({ term : term }),
dfd = $.Deferred(),
search;
app.set('currentSearch', term);
if (term) {
if (existing.length) {
search = existing[0];
search.update();
} else {
search = new Search({ term : term });
searches.add(search);
}
searchData.fetch({ data : { term : term } })
.then(dfd.resolve, dfd.reject)
.always(searchForm.release);
app/controllers/search
Thursday, June 28, 12