c# - Dropzone.js already attached -


i've implemented dropzone in project working great. except browser decides throw error whenever page request clarity have trimmed view down quite long, below html lives inside form (not sure if cause issue anyway) have 1 reference dropzone shown here, dropzone.js included inside bundle config again 1 occurrence.

error : if(this.element.dropzone)throw new error("dropzone attached.")

this view

<div class="form-group">     <div class="col-xs-12 dropzone" id="uploadimage">          <input type="file" id="id-input-file-2" />      </div> </div> 

this how create dropzone

 $(document).ready(function () {          $("div#uploadimage").dropzone({ url: '@url.action("saveuploadedfile", "person")' });  }); 

and controller follows

 public actionresult saveuploadedfile()     {         bool success = true;          string fname = string.empty;          try         {             foreach (var file in request.files.cast<string>().select(filename => request.files[filename]).where(file => file != null))             {                 fname = file.filename;                  if (file.contentlength > 0)                 {                    // write rest of code here                 }             }         }         catch (exception ex)         {             success = false;         }          return json(success ? new { message = fname } : new { message = "error in saving file" });     } 

now i'm able retrieve images within controller uncertain on in code dropzone being initialized again resulting in above error.

update

after trying daves suggestion jquery looks this

$(document).ready(function () {          dropzone.options.myawesomedropzone = false;          $("div#uploadimage").dropzone({             url: '@url.action("saveuploadedfile", "person")',             addremovelinks: true,             removedfile: function (file) {                 var name = file.name;                 $.ajax({                     type: 'post',                     url: '@url.action("deleteuploadedfile", "person")',                     data: "id=" + name,                     datatype: 'html'                 });                 var ref;                 return (ref = file.previewelement) != null ? ref.parentnode.removechild(file.previewelement) : void 0;             },             maxfilesize: 2,             maxfiles: 12,          }); }); 

but yet still error.

try reference here

  1. turn off autodiscover globally this: dropzone.autodiscover = false;, or

  2. turn off autodiscover of specific elements this: dropzone.options.myawesomedropzone = false;


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -