Question: How to trigger something (function) on adding asset?
Hi, @artf. What is the correct way to trigger a function when an asset is added to the assets by providing the link and then pressing the 'Add Image' button?
I am running the open-assets command on an onclick event of a button in a custom panel and then trying to call a function when an image is added to the assets.
I am using the following code to trigger a function on adding an image:
editor.on('asset:add', () => {
// my code
})
The // my code part is running multiple times. (As many times as I open the asset dialog using the button mentioned before)
What am I possibly doing wrong?
Sorry @theSC0RP but I really don't understand what is your issue here. Are you able to provide a live example and clarify the steps?
Hey, @artf. I fixed the issue by changing the structure of my code. I was doing something wrong (my guess is that multiple instances of asset manager were open which ran the // my code part multiple times)