small refactoring around router.js

This commit is contained in:
Dennis Collinson 2012-02-24 14:30:11 -08:00
parent 2c0cfa53dc
commit 5154500239
3 changed files with 11 additions and 11 deletions

View file

@ -26,7 +26,8 @@ module Diaspora
# Add additional load paths for your own custom dirs
#config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/presenters)
#OMG HAX PLZ FIX MAKE ALL LIB AUTOLOAD KTHNX
config.autoload_paths += %W(#{config.root}/lib/*)
config.autoload_paths += %W(#{config.root}/lib/*/*)
config.autoload_paths += %W(#{config.root}/lib/*/*/*)

View file

@ -9,8 +9,10 @@ app.pages.PostViewer = app.views.Base.extend({
"#header-container" : "authorView"
},
initialize : function() {
this.initViews();
initialize : function(options) {
this.model = new app.models.Post({ id : options.id });
this.model.fetch().success(_.bind(this.initViews, this));
this.prepIdleHooks();
$(document).bind("keypress", _.bind(this.commentAnywhere, this))
@ -28,6 +30,8 @@ app.pages.PostViewer = app.views.Base.extend({
templateName : "post-viewer/content/" + this.model.get("templateName"),
attributes : {"data-template" : this.model.get("templateName")}
});
this.render();
},
prepIdleHooks : function () {

View file

@ -39,14 +39,9 @@ app.Router = Backbone.Router.extend({
},
singlePost : function(id) {
new app.models.Post({id : id}).fetch({success : function(resp){
var page = new app.pages.PostViewer({
model : new app.models.Post(resp)
}).render();
var page = new app.pages.PostViewer({ id: id }).render();
$("#container").html(page.el);
}})
}
});