Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created November 19, 2009 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/238966 to your computer and use it in GitHub Desktop.
Save matschaffer/238966 to your computer and use it in GitHub Desktop.
jQuery.fn.dataWithoutTriggering = jQuery.fn.data;
jQuery.fn.data = function(key, value) {
var r = this.dataWithoutTriggering(key, value);
if (typeof(value) != "undefined") {
this.trigger('data', [key, value]);
}
return r;
};
$(model).bind('data', function(key, value) {
... do custom stuff here if you want ...
});
function onData(boundKey, fn) {
$(document).bind('data', function(key) {
if (key == boundKey) fn();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment