knockout.js - Using dropzone.js within a knockout binding -


i trying dropzone work knockout binding. able to...

ko.bindinghandlers.dropzone = {     init: function(element, valueaccessor, allbindingsaccessor, bindingcontext) {         $(element).dropzone({ url: 'some/tightly/bound/uri});     } } 

.. cannot. uri dynamic based on data entered in viewmodel, have come far:

var dropzoneobject; // should this.dropzoneobject  ko.bindinghandlers.dropzone = {     init: function(element, valueaccessor, allbindingsaccessor, bindingcontext) {         var url = allbindingsaccessor().urlpath || "unknown";         dropzoneobject = new dropzone("div#" + element.id, {             url: url,              init: ...,             etc         });     },     update: function(element, valueaccessor, allbindingsaccessor, bindingcontext) {         var url = allbindingsaccessor().urlpath || "unknown";         dropzoneobject.options = {             url: url         };     } } 

but when test this, following error:

uncaught typeerror: cannot read property 'trim' of undefineddropzone.defaultoptions.addedfile  @ dropzone.js:252emitter.emit @ dropzone.js:58dropzone.addfile  @ dropzone.js:956(anonymous function) @ dropzone.js:563 

why undefineddropzone? have missed?

thanks

found answer, update method on writing options (including default ones) rather updating so:

.... update: function(element, valueaccessor, allbindingsaccessor, bindingcontext) {     var url = allbindingsaccessor().urlpath || "unknown";     dropzoneobject.options = {         url: url     }; } .... 

should read:

update: function(element, valueaccessor, allbindingsaccessor, bindingcontext) {     var url = allbindingsaccessor().urlpath || "unknown";     dropzoneobject.options.url = url; } 

hope helps someone!


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -