How to set src of video tag at dynamic?
I think I have something like that made with a custom component. Maybe it helps
Read full answer below βQuestion
Hi @artf , Hi I have drag and drop video tag and button from blockmanager, On Clicking the button , I need to change the url to src. But not working, Please guide me. editor.BlockManager.add("html/video", { label: <div> <img src="../../../Images/SiteBuilder/video.svg"/> <div class="my-label-block">Video</div> </div>, category: 'UI Controls', tab: 'UI Controls', id: 'UI Controls', content: <video id="video1" src="../../../Images/Jotun/Media21-1.m4v"id="TestVideo" controls type="video/mp4">, }); Button Event: va url = "../../test.mp4"; $("#video1").attr('src', url); Its not applied, Let me know...
Answers (4)
I think I have something like that made with a custom component. Maybe it helps
If you need to update only the block content (eg. the change will be applied on new dragged blocks) you can change it in this way: if you need to change Components in the canvas, I'd recommend reading more in detail Components
,Thanks @artf and stf1981 for your response, Actually I drag and drop multiple videos with generated Random number to Id attribute. In this case How to update src specific selected video?
I gets failed to update src.
Thanks for reporting this, @san-123. Great question about How to set src of video tag at dynamic?. The recommended approach with GrapesJS is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3631
How to load dynamic content in the final HTML file?
I looked everywhere, including the issues section and tried a few things. But really unsure how to load dynamic content in my components al...
Issue #3218
How to add new HTML element with inline styles?
I would like to add a new HTML element, with inline styles, around the rte.selection(). With the following example, the HTML is OK, but pro...
Issue #6348
It's possible to drag and drop literally anything inside grapesjs canvas
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://grap...
Issue #5388
Running Headless Mode Returns Different HTML from Editor
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? ChromeV117.0.5938.62 Reproducible demo lin...
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.
Tutorial
How to Build an AI-Powered Page Builder with GrapesJS in 2026
What we learned building GJSDocs β from simple AI text generation to structured, context-aware visual editing
Tutorial
How Much Does It Cost to Build a SaaS Page Builder in 2026?
How much does it cost to build a SaaS page builder in 2026? Explore realistic development costs, timelines, features, and how using GrapesJS can reduce
Tutorial
PageKit: the GrapesJS application you'd have to build anyway
A source-available Next.js app around the open-source GrapesJS core β publishing, custom domains, leads, checkout and a plugin loader.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.