Created
December 15, 2010 08:51
-
-
Save hdragomir/741786 to your computer and use it in GitHub Desktop.
Quick jQuery plugin to parse data from an element and store it on the element via jQuery.data
This file contains hidden or 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
(function($){ | |
$.fn.parseData = function(){ | |
return $(this).filter('[js-data]').each(function(){ | |
var data = jQuery.parseJSON($(this).attr('js-data')), prop; | |
for(prop in data) | |
$(this).data(prop, data[prop]); | |
}).end(); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment