Skip to content

Instantly share code, notes, and snippets.

@scottdorman
Last active August 29, 2015 14:04
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 scottdorman/c0e86686072df3930372 to your computer and use it in GitHub Desktop.
Save scottdorman/c0e86686072df3930372 to your computer and use it in GitHub Desktop.
A custom Knockout binding handler for embedding gists.
ko.bindingHandlers.gistEmbed = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
var $element, options, gist;
options = ko.utils.unwrapObservable(valueAccessor());
$element = $(element);
$element.data('gist-id', options.gistid);
$element.data('gist-file', options.file);
$element.data('gist-hide-footer', options.hidefooter || 'false');
$element.data('gist-hide-line-numbers', options.hidelinenumbers || 'false');
$element.gist();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment