Question

I have a bootstrap modal with a dropzone form inside of it. I'm wanting to load a list of images from the server on modal.show() and give the user the ability to remove or add images from dropzone. I've read the wiki here that shows how to insert a mock file in the init function, but that is being called before my ajax call to retrieve the list of images has returned.

If I manually type in the url to the image in the dropzone init function, it shows up fine. Is there another way to add a file outside of the init function? Thanks!!

Était-ce utile?

La solution

Looks like I answered my own question....the magic of closures! I knew this Secrets of the Javascript Ninjas book would come in handy! I basically created a function inside of the Dropzone init function that returned the instance of dz and assigned it to an outer variable. In the modal's edit button click event I call a web service to retrieve my images and the inner function returning my dz instance. I then use that instance to load the pictures via the wiki link code.

If anyone has this same issue and wants to see code, let me know!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top