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)
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)
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.
Issue #2350
[Question] How do I add elements/sectors to views container using a custom button in the Panel
I have added a custom button to the Panel as below: const pm = editor.Panels; pm.addButton('views', { id: 'customButton', className: '', co...
Issue #2280
[Question] How to show the traits manager button/panel
Hi, I must be missing something basic, but how do I add the traits manager panel without adding a plugin? The newsletter plugin has it adde...
Issue #1112
[Question]How to add a new event to asset images
Hello, is there a way to add a new event to the AssetImageView, something like 'onRemove'. I overwritten the addAsset function from asset m...
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.