Skip to content

Instantly share code, notes, and snippets.

@csquared
Created January 7, 2011 17:29
Show Gist options
  • Save csquared/769781 to your computer and use it in GitHub Desktop.
Save csquared/769781 to your computer and use it in GitHub Desktop.
Getting javascript objects back from a #to_json call
jQuery.fn.dataAttr = function(data_attr_name) {
var data = eval('(' + this.attr("data-" + data_attr_name) + ')')
return data || {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment