Created
August 27, 2014 03:58
-
-
Save polikeiji/f0f5b2b80610accb9665 to your computer and use it in GitHub Desktop.
knockout.jsでdropzone.jsを使う為のカスタムバインディング。
This file contains 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
ko.bindingHandlers.dropzone = | |
init: (element, value_accessor) -> | |
passed_value = ko.unwrap value_accessor() | |
send_data = passed_value.data | |
$target = $(element).dropzone | |
url: passed_value.url | |
sending: (file, xhr, form_data) -> | |
for name, value of send_data | |
if typeof(value) == "function" | |
form_data.append name, value() | |
else | |
form_data.append name, value | |
addedfile: () -> | |
paramName: "image" | |
$target.bind "uploadprogress", passed_value.upload_progress_handler | |
$target.bind "success", passed_value.success_handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment