Reputation: 7852
I have a file upload component which is bound through a template to a view model (UploadViewModel
). The file upload dialog is initialized through a custom Knockout binding (uploadFileDialog
). The UploadViewModel is created when the user clicks the 'Choose file...' button and when the user has selected a file to upload the fileuploadadd
event should trigger which should invoke fileSelected
method and then the Start button should be visible as a result. This doesn't seem to happen. The only way to make it work is to re-initialize the file upload dialog every time (the commented code in the uploadSelectFile
method).
Why does it need to be re-initialized?
Code: http://jsfiddle.net/FKYwB/
Upvotes: 0
Views: 64
Reputation: 8053
Your event is never fired.
Actually, you are not binding to the right element.
Your uploadFileDialog
should be on the form
tag in the template like this:
<form id="fileupload" action="" method="POST" enctype="multipart/form-data"
data-bind="uploadFileDialog: { maxFileSize: 500000000, autoUpload: false },
event: { fileuploadadd: fileSelected}">
<!-- -->
</form>
Upvotes: 1