Created
November 14, 2011 20:37
-
-
Save wilsolutions/1365072 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($) { | |
| window.Insight = Backbone.Model.extend({ | |
| view: function(index) { | |
| //return this.get('innovations')[index]; | |
| console.log(this.get('innovations')[index]); | |
| } | |
| }); | |
| window.Insights = Backbone.Collection.extend({ | |
| model: Insight, | |
| url: 'http://locahost.library/items.json', | |
| viewIndex: function(id) { | |
| console.log(id); | |
| console.log('# viewIndex called, ID: ' + id); | |
| insightView = new InsightView({model:library}); | |
| $('#product').append(insightView.render().el); | |
| //this.InsightView.render(); | |
| }, | |
| sortByDate: function() { | |
| console.log(this); | |
| return; | |
| }, | |
| sortByPopular: function() { | |
| return; | |
| }, | |
| sortByTopRated: function() { | |
| return; | |
| }, | |
| sortByName: function() { | |
| return; | |
| } | |
| }); | |
| window.library = new Insights(); | |
| window.LibraryView = Backbone.View.extend({ | |
| template: "#library-template", | |
| tag: "div", | |
| initialize: function() { | |
| window.library.fetch(); | |
| _.bindAll(this, 'render'); | |
| this.initializeTemplate(); | |
| }, | |
| initializeTemplate: function() { | |
| this.template = Handlebars.compile($(this.template).html()); | |
| }, | |
| render: function() { | |
| var data = this.model.toJSON(); | |
| $(this.el).html(this.template(data[0])); | |
| console.log('#LOG#: Rendered LibraryView...'); | |
| return this; | |
| }, | |
| }); | |
| window.InsightView = Backbone.View.extend({ | |
| template: "#insight-template", | |
| tag: "div", | |
| initialize: function() { | |
| console.log('#CALLED#: initialize...'); | |
| _.bindAll(this, 'render'); | |
| this.initializeTemplate(); | |
| }, | |
| initializeTemplate: function() { | |
| console.log('#CALLED#: initializeTemplate View...'); | |
| this.template = Handlebars.compile($(this.template).html()); | |
| }, | |
| render: function() { | |
| console.log('#CALLED#: render Insight View...'); | |
| // $(this.el).html(this.template(this.model.toJSON()); | |
| return this; | |
| }, | |
| }); | |
| window.InsightsApp = Backbone.Router.extend({ | |
| routes: { | |
| "":"home", | |
| "home":"home", | |
| "insight/:id":"insight", | |
| }, | |
| initialize: function() { | |
| //window.library.fetch(); | |
| this.libraryView = new LibraryView({model:library}); | |
| console.log('## ROUTERRRRRRRR!!!!'); | |
| $('#library div').empty(); | |
| $('#library div').append(this.libraryView.render().el); | |
| }, | |
| home: function() { | |
| console.log('Home Called'); | |
| // $('#library div').empty(); | |
| $('#library div').append(this.libraryView.render().el); | |
| }, | |
| insight: function(id) { | |
| console.log('Insights route called for '+id) | |
| } | |
| }); | |
| window.App = new LibraryView(); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment