All pastes #2131281 Raw Edit

Unnamed

public javascript v1 · immutable
#2131281 ·published 2012-03-23 03:33 UTC
rendered paste body
(function($){$(function(){	window.App = {}	window.App.Templates = {}	App.Templates.postTemplate = $('#postTemplate').html();		App.PostsView = Backbone.View.extend({		id: 'posts',		render: function(){			this.collection.each(this.addOne(), this)		},		addOne: function(post){			var view = new App.PostView({model: post})			view.render()			this.$el.append(view.el)		}	})		App.PostView = Backbone.View.extend({		class: 'post',		template: function(){			var html = _.template('<%= title %>', {title: 'dero'})			return html		},		render: function(){			this.$el.html(this.template())		}	})		App.Post = Backbone.Model.extend({			})		App.Posts = Backbone.Collection.extend({		model: App.Post,		url: 'api/get_recent_posts/',		parse: function(resp){return resp.posts}	})		App.posts = new App.Posts	App.posts.fetch()	App.postView = new App.PostsView({collection: App.posts, el: '#main'})	App.postView.render();	})})(jQuery)