add existing is almost done.

This commit is contained in:
Keivan Beigi
2013-01-31 19:15:19 -08:00
committed by kay.one
parent 023eaca678
commit 4176e7e9e4
12 changed files with 98 additions and 57 deletions

View File

@@ -35,7 +35,7 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
onRender: function () {
console.log('binding auto complete');
var self = this;
this.ui.seriesSearch
.data('timeout', null)
.keyup(function () {
@@ -48,14 +48,16 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
},
search: function (context) {
context.abortExistingRequest();
var term = context.ui.seriesSearch.val();
context.collection.reset();
if (term !== '') {
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
context.collection.fetch({
context.currentSearchRequest = context.collection.fetch({
data: $.param({ term: term }),
success: function (model) {
context.resultUpdated(model, context);
@@ -67,6 +69,13 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
}
},
abortExistingRequest : function () {
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
console.log('aborting previous pending search request.');
this.currentSearchRequest.abort();
}
},
resultUpdated: function (options, context) {
_.each(options.models, function (model) {