Skip to content

Instantly share code, notes, and snippets.

@levidehaan
Created March 1, 2012 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levidehaan/1946646 to your computer and use it in GitHub Desktop.
Save levidehaan/1946646 to your computer and use it in GitHub Desktop.
example
var render = function(template, context) {
var chez, divm = template.replace(/-.*$/, "");
if( typeof context === "function") {
switch(true) {
case (context.toString().indexOf("playlists") > 0):
$.when(context()).then(function(data) {
$(divm).link(data, template).listview();
$(template).template();
$(divm).render();
$(divm).trigger('create');
$('#main').show();
$('#loader').hide();
});
break;
}
} else {
$(divm).link(context, template);
$(template).template("ref");
$(divm).trigger('create');
}
$.mobile.silentScroll(0);
$.mobile.hidePageLoadingMsg();
};
//init the app, load all the basics first, then on to specialized things
$(document).live('pagebeforecreate', function(event) {
$.mobile.loadingMessage = "Loading Khan Academy Content";
if(event.target.id === "about") {
$('#main').page();
$('#contentmain').hide();
$('#contentleft').hide();
}
if(event.target.id === "main") {
//console.log("rendering templates...");
render('#header-template', {
title : ""
});
render('#leftbar-template', {
list : "list"
});
render('#contentmain-template', {
content : ""
});
render('#contentleft-template', function() {
var dfd = new $.Deferred();
arequest.playlists(dfd);
return dfd.promise();
});
render('#footer-template', {
footer : "KABook"
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment