Skip to content

Instantly share code, notes, and snippets.

@csim
Last active August 30, 2016 14:18
Show Gist options
  • Save csim/4513ae3316104e6f474d to your computer and use it in GitHub Desktop.
Save csim/4513ae3316104e6f474d to your computer and use it in GitHub Desktop.
Dropzone Knockout binding
ko.bindingHandlers.dropzone = {
init: function(element, valueAccessor)
{
var value = ko.unwrap(valueAccessor());
var options = {
maxFileSize: 15,
createImageThumbnails: false,
};
$.extend(options, value);
$(element).addClass('dropzone');
new Dropzone(element, options); // jshint ignore:line
}
};
<div data-bind="dropzone: { url: '/upload', success: attachmentSuccess }"></div>
@phily245
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment