From 274b1528f2374f29afb058c32635ae118de51099 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 22 Jan 2013 21:48:22 -0800 Subject: [PATCH] series search displays the result using auto binder. --- .../AddNewSeries/AddNewSeriesView.js | 25 ++++++++----------- .../AddNewSeries/SearchResultTemplate.html | 3 ++- NzbDrone.Web/_backboneApp/app.js | 4 ++- NzbDrone.Web/_backboneApp/errorHandler.js | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js index 4c095ee59..137825dc6 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js @@ -4,29 +4,24 @@ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({ - tagName: 'li', template: "AddSeries/AddNewSeries/SearchResultTemplate", - itemView: NzbDrone.AddSeries.SearchResultModel, - - + className: 'row', initialize: function () { - - this.collection = new NzbDrone.AddSeries.SearchResultCollection(); - this.bindTo(this.collection, 'reset', this.render); + this.listenTo(this.model, 'reset', function () { alert('model'); }); }, + onRender: function () { + NzbDrone.ModelBinder.bind(this.model, this.el); + } + }); NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({ - tagName: 'ul', className: 'result', - itemView: NzbDrone.AddSeries.SearchResultModel, - - collection : new NzbDrone.AddSeries.SearchResultCollection(), + itemView: NzbDrone.AddSeries.SearchItemView, initialize: function () { - //this.collection = new NzbDrone.AddSeries.SearchResultCollection(); this.listenTo(this.collection, 'reset', this.render); }, @@ -56,10 +51,10 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ clearTimeout(self.$el.data('timeout')); self.$el.data('timeout', setTimeout(self.search, 500, self)); }); - - this.searchResult.show(new NzbDrone.AddSeries.SearchResultView()); + + this.searchResult.show(new NzbDrone.AddSeries.SearchResultView({ collection: this.collection })); }, - + search: function (context) { var term = context.ui.seriesSearch.val(); diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html index ea2685331..3819e404d 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html @@ -1,3 +1,4 @@ 
-

result

+
+
diff --git a/NzbDrone.Web/_backboneApp/app.js b/NzbDrone.Web/_backboneApp/app.js index bc7cf21d1..24de3d2c4 100644 --- a/NzbDrone.Web/_backboneApp/app.js +++ b/NzbDrone.Web/_backboneApp/app.js @@ -1,8 +1,10 @@ /// /// /// +/// /// /// +/// /// /// @@ -13,7 +15,7 @@ if (typeof console == "undefined") { NzbDrone = new Backbone.Marionette.Application(); NzbDrone.AddSeries = NzbDrone.module("AddSeries"); - +NzbDrone.ModelBinder = new Backbone.ModelBinder(); NzbDrone.Constants = { diff --git a/NzbDrone.Web/_backboneApp/errorHandler.js b/NzbDrone.Web/_backboneApp/errorHandler.js index 58f2e6277..955a67e8d 100644 --- a/NzbDrone.Web/_backboneApp/errorHandler.js +++ b/NzbDrone.Web/_backboneApp/errorHandler.js @@ -4,7 +4,7 @@ window.onerror = function (msg, url, line) { alert("Error: " + msg + "\nurl: " + url + "\nline #: " + line); - var suppressErrorAlert = true; + var suppressErrorAlert = false; // If you return true, then error alerts (like in older versions of // Internet Explorer) will be suppressed. return suppressErrorAlert;