Created
April 27, 2009 19:21
-
-
Save jimmac/102663 to your computer and use it in GitHub Desktop.
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
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