Permalink
Browse files

step-7 route phone show view

  • Loading branch information...
204NoContent committed Apr 9, 2014
1 parent 16a6b1e commit 7742e711fdef7a9ced88e8270b9ac417626bacdc
@@ -40,3 +40,12 @@ __p+='<a href="/phones/'+
}
return __p;
};
window.JST["phones/show"] = function(obj){
var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};
with(obj||{}){
__p+='TBD: detail view for '+
((__t=( get('id') ))==null?'':_.escape(__t))+
'\n';
}
return __p;
};
@@ -1 +1,3 @@
Phone = Backbone.Model;
Phone = Backbone.Model.extend({
urlRoot: '/api/phones'
});
@@ -2,9 +2,17 @@ Router = Backbone.Router.extend({
routes: {
'': 'phonesIndex',
'phones/:id': 'phonesShow'
},
phonesIndex: function () {
new PhonesIndexView({ el: 'section#main' });
},
phonesShow: function (id) {
new PhonesShowView({
el: 'section#main',
model: new Phone({ id: id })
});
}
});
@@ -0,0 +1 @@
TBD: detail view for [[= get('id') ]]
@@ -0,0 +1,12 @@
PhonesShowView = Backbone.View.extend({
initialize: function () {
this.model.fetch();
this.listenTo(this.model, 'sync', this.render);
},
render: function () {
this.$el.html(JST['phones/show'](this.model));
}
});
View
@@ -17,6 +17,7 @@
<script src="/javascripts/collections/phones_collection.js"></script>
<script src="/javascripts/views/phones/show_view.js"></script>
<script src="/javascripts/views/phones/index_view.js"></script>
<script src="/javascripts/views/phones/filter_view.js"></script>
<script src="/javascripts/views/phones/index_list_view.js"></script>

0 comments on commit 7742e71

Please sign in to comment.