Created
April 21, 2012 17:04
-
-
Save dcabines/2438439 to your computer and use it in GitHub Desktop.
This is how the about page works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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