Skip to content

Instantly share code, notes, and snippets.

@pjhoberman
Created December 8, 2010 23:33
Show Gist options
  • Save pjhoberman/734111 to your computer and use it in GitHub Desktop.
Save pjhoberman/734111 to your computer and use it in GitHub Desktop.
$.extend( {
updateBlock: function(url, options, callback){
// this stuff isn't needed right now, but it's for adding options
$.updateBlock.defaults = {
//formatDate: [] // expects an array of ids to format
}; // defaults
$.updateBlock.options = $.extend({}, $.updateBlock.defaults, options || {});
$.get(url, function(data){
var r = data.output; // r for record
for (var key in r) {
if (r.hasOwnProperty(key)) {
if( typeof r[key] == 'object' ) // units and values
$( '#' + key ).text( quantity(r[key]));
else
{
if( r[key] == '' && typeof r[key] == 'string' ) // for blank strings
r[key] = '--';
$( '#' + key ).text( r[key] );
} // else
} // if
} // for
if( typeof callback == 'function' )
callback.call(this);
}); // get
}
}); // extend
@tbeseda
Copy link

tbeseda commented Dec 15, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment