series search displays the result using auto binder.

pull/6/head
kay.one 12 years ago
parent f98002c576
commit 274b1528f2

@ -4,29 +4,24 @@
NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
tagName: 'li',
template: "AddSeries/AddNewSeries/SearchResultTemplate", template: "AddSeries/AddNewSeries/SearchResultTemplate",
itemView: NzbDrone.AddSeries.SearchResultModel, className: 'row',
initialize: function () { initialize: function () {
this.listenTo(this.model, 'reset', function () { alert('model'); });
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
this.bindTo(this.collection, 'reset', this.render);
}, },
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
}
}); });
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({ NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
tagName: 'ul',
className: 'result', className: 'result',
itemView: NzbDrone.AddSeries.SearchResultModel, itemView: NzbDrone.AddSeries.SearchItemView,
collection : new NzbDrone.AddSeries.SearchResultCollection(),
initialize: function () { initialize: function () {
//this.collection = new NzbDrone.AddSeries.SearchResultCollection();
this.listenTo(this.collection, 'reset', this.render); this.listenTo(this.collection, 'reset', this.render);
}, },
@ -57,7 +52,7 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
self.$el.data('timeout', setTimeout(self.search, 500, self)); 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) { search: function (context) {

@ -1,3 +1,4 @@
<div> <div>
<h3>result</h3> <div name="SeriesName"/>
<div name="FirstAired"/>
</div> </div>

@ -1,8 +1,10 @@
/// <reference path="JsLibraries/jquery.js" /> /// <reference path="JsLibraries/jquery.js" />
/// <reference path="JsLibraries/underscore.js" /> /// <reference path="JsLibraries/underscore.js" />
/// <reference path="JsLibraries/backbone.js" /> /// <reference path="JsLibraries/backbone.js" />
/// <reference path="JsLibraries/backbone.modelbinder.js" />
/// <reference path="JsLibraries/backbone.marionette.js" /> /// <reference path="JsLibraries/backbone.marionette.js" />
/// <reference path="JsLibraries/backbone.marionette.extend.js" /> /// <reference path="JsLibraries/backbone.marionette.extend.js" />
/// <reference path="JsLibraries/backbone.modelbinder.js" />
/// <reference path="JsLibraries/bootstrap.js" /> /// <reference path="JsLibraries/bootstrap.js" />
/// <reference path="errorHandler.js" /> /// <reference path="errorHandler.js" />
@ -13,7 +15,7 @@ if (typeof console == "undefined") {
NzbDrone = new Backbone.Marionette.Application(); NzbDrone = new Backbone.Marionette.Application();
NzbDrone.AddSeries = NzbDrone.module("AddSeries"); NzbDrone.AddSeries = NzbDrone.module("AddSeries");
NzbDrone.ModelBinder = new Backbone.ModelBinder();
NzbDrone.Constants = { NzbDrone.Constants = {

@ -4,7 +4,7 @@ window.onerror = function (msg, url, line) {
alert("Error: " + msg + "\nurl: " + url + "\nline #: " + 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 // If you return true, then error alerts (like in older versions of
// Internet Explorer) will be suppressed. // Internet Explorer) will be suppressed.
return suppressErrorAlert; return suppressErrorAlert;

Loading…
Cancel
Save