Skip to content

Instantly share code, notes, and snippets.

@dcabines
Created April 21, 2012 17:04
Show Gist options
  • Save dcabines/2438439 to your computer and use it in GitHub Desktop.
Save dcabines/2438439 to your computer and use it in GitHub Desktop.
This is how the about page works.
This is the about page.
It uses the Facebook component to pull my public information and populate a table with it.
It caches the data so it is only fetched once.
<h1>About</h1>
<div class="row">
<div class="span4">
<table class="table table-bordered">
<tbody>
<tr>
<td>Name</td>
<td><%= name %></td>
</tr>
<tr>
<td>Profile</td>
<td><a href="<%= link %>" target="_blank"><%= link %></a></td>
</tr>
<tr>
<td>Gender</td>
<td><%= gender %></td>
</tr>
</tbody>
</table>
</div>
</div>
define(['facebook', 'text!templates/about.html'], function (facebook, template) {
var data = {
myinfo: null,
populate: function (callback) {
if (data.myinfo == null)
facebook.info(function (fbdata) {
data.myinfo = fbdata;
callback(data.myinfo);
}, '301800493');
else callback(data.myinfo);
}
};
var view = Backbone.View.extend({
el: '.content',
render: function () {
var el = this.$el;
data.populate(function (user) {
var compiledTemplate = _.template(template, user);
el.html(compiledTemplate);
$('.nav li:nth-child(1)').addClass('active').siblings().removeClass('active');
});
}
});
return view;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment