Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

templates are added for views instead of ugly embedded html

  • Loading branch information...
commit 7ea9d72974dcda4bde85c796a0bdc698f3425254 1 parent 829827b
@serdary authored
View
5 app/assets/javascripts/backbone/templates/feeds/feed.jst.ejs
@@ -0,0 +1,5 @@
+<td><%= from_name %></td>
+<td><%= message %></td>
+<td><%= feed_type %></td>
+<td><%= like_count %></td>
+<td><a href="#/<%= id %>">Show</td>
View
1  app/assets/javascripts/backbone/views/feeds/feed_view.js
@@ -1,4 +1,5 @@
App.Views.FeedView = Backbone.View.extend({
+ tagName: "tr",
render: function() {
var template = JST["backbone/templates/feeds/feed"];
$(this.el).html(template(this.model.attributes))
View
13 app/assets/javascripts/backbone/views/feeds/index_view.js
@@ -10,21 +10,12 @@ App.Views.IndexView = Backbone.View.extend({
}
for (var i = 0; i < this.feeds.models.length; i++)
- this.addOne(this.feeds.models[i].attributes);
+ this.addOne(this.feeds.models[i]);
},
addOne: function(feed) {
-
- var view = '';
- var template = '<tr><td>[from_name]</td><td>[message]</td><td>[feed_type]</td><td>[like_count]</td><td><a href="#/[id]">Show</td></tr>';
- view = template.replace('[from_name]', feed.from_name).replace('[message]', feed.message)
- .replace('[feed_type]', feed.feed_type).replace('[like_count]', feed.like_count).replace('[id]', feed.id);
-
- $(this.el).find("tbody").append(view);
-/*
-
var view = new App.Views.FeedView({ model: feed });
- $(this.el).find("tbody").append(view.render().el);*/
+ $(this.el).find("tbody").append(view.render().el);
},
render: function() {
Please sign in to comment.
Something went wrong with that request. Please try again.