0

I have a object like this

Dropzone.options.dropzoneForm = {
  addRemoveLinks: true,
  init: function () {
    //upload process
  }
}; 

from another method, I can create a object of this class and pass parameter like

myDropzone = new dropzoneForm();
myDropzone.addRemoveLinks = false; //something like this works perfectly. 

But I need to achieve another thing like

myDropzone.removedFile: function(){
//do something}

How can I achieve this, please suggest me.

Sohail Ashraf
  • 10,078
  • 2
  • 26
  • 42
Sam
  • 29
  • 1
  • 1
    Hi Sam, please try to rephrase your questions of what you are having issues with. Your question is not 100% clear. What is the issue exactly with removeFile you cannot make happen? Maybe give an example of what you've tried? – Dory Zidon Apr 13 '20 at 05:21
  • You do not need to do `new`. `dropzoneForm` is a object literal and not a class. Either set it as a constructor or directly consume the object – Rajesh Apr 13 '20 at 05:24
  • May be this can help. https://stackoverflow.com/a/39419794/4903314 https://stackoverflow.com/a/13522017/4903314 – Umair Khan Apr 13 '20 at 05:24
  • Something like. `myDropzone.prototype.removedFile: function(){ //do something}` – Umair Khan Apr 13 '20 at 05:25

2 Answers2

2

If you want to add this method to dropzoneForm use prototype but if you want to add this method to myDropzone you can do this easily :

myDropzone.removedFile = function(){
};
halfer
  • 19,824
  • 17
  • 99
  • 186
0

Use prototype to add method to your Object

dropzoneForm.prototype.removedFile = function(){
    // do something
}
var inst = new dropzoneForm();
inst.removedFile();
jsduniya
  • 2,464
  • 7
  • 30
  • 45