Skip to content

Instantly share code, notes, and snippets.

@jimmac
Created April 27, 2009 19:21
Show Gist options
  • Save jimmac/102663 to your computer and use it in GitHub Desktop.
Save jimmac/102663 to your computer and use it in GitHub Desktop.
YAST = {}; //the one global object
YAST.modules = {
// data will be pulled from JSON:
// group
// |
// - section
// |
// - item
'data': {},
// 'gotData': false,
'readJSON': function(uri) {
//var callback = callback || function(){};
var that = this;
//HERE
$.getJSON(uri, function (data) {
that.data = data;
//now I wish to call render() and pass the result to who called me wth return, but that ends up HERE
return that.render();
});
},
'render': function () {
var html = [],
data = this.data;
//console.log(data);
$.each(data, function (group, sections) {
html.push('<h1>', group, '</h1>');
});
return html.join('');
},
'debug': function () {
console.info(this);
}
};
//this ends up blank, as readJSON() won't return anything
'$container.html(YAST.modules.readJSON('inc/fake-data.js'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment