johndatserakis / file-upload-with-preview

🖼 Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well with or without a framework.

Home Page:https://johndatserakis.github.io/file-upload-with-preview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Added event confusion with presets and new add

manchumahara opened this issue · comments

It seems if some presetss images/files are loaded the added event triggers same way if the new files are added after the page load.
How can we differentiate between the two condition. On added event I need to send ajax request to upload the image, but what I find is presets are also triggering the same event.

Hmm yes I see what you're saying. I'm not sure if this is something I'd consider adding right away - as there is an easy way to check whether the event is from the preset images. To accomplish this I would just check the result of the event with what you know to be the preset images.

If they match - then you know they are the preset images. If not, you know you're in a non-preset event.

Thank you for your answer. Can you please write sample code how you check the event if from preset or from new?