How to trigger something (function) on adding asset?
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)
Read full answer below ↓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: 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 #3415
Custom Asset Manager. How to set bg image
Hi there! I'm building a custom modal for the Asset Manager and basically, it seems that I need to override command. How I can understand i...
Issue #3237
Add Trait For wrapper
Hi @artf I've added trait for wrapper this way. How can I perform the init function for the same Here is the code @artf Could you please he...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.