Skip to content

Instantly share code, notes, and snippets.

@jasonhofer
Created August 28, 2018 15:31
Show Gist options
  • Save jasonhofer/65427182e8bdcb8e2e1db6f4d4a6e195 to your computer and use it in GitHub Desktop.
Save jasonhofer/65427182e8bdcb8e2e1db6f4d4a6e195 to your computer and use it in GitHub Desktop.
jQuery.fn.dataBind = function (bindings) {
if (this.length) {
var pairs = [];
for (var name in bindings) {
if (bindings.hasOwnProperty(name)) {
pairs.push(name + ': ' + bindings[name]);
}
}
this.attr('data-bind', pairs.join(', '));
}
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment