Issue #3111Opened November 3, 2020by theSC0RP1 reactions

Question: How to trigger something (function) on adding asset?

Question

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?

Answers (2)

theSC0RPNovember 9, 20201 reactions

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)

artfNovember 9, 20200 reactions

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?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.