Created
September 26, 2014 10:18
-
-
Save hergaiety/a17fb0d69ade53da2e47 to your computer and use it in GitHub Desktop.
Ensures data-* updates the attribute when the real data is updated.
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
/** | |
* Ensures the data-* is updated visually when the data is updated by jQuery | |
* Example: $('.foo').data('bar', 'value').trigger('changeData'); | |
*/ | |
$(document).on('changeData', '.foo', function(e) { | |
$(this).attr('data-bar', $(this).data('bar')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment