[QUESTION] ID changes when importing html or passing html in components prop in config.
Question
Hi,
I built a component and block that I can drag and drop in the canvas.
My issue is that some styles rely on the ID. I know this might not be ideal, but it's like this at the moment.
My problem is when I reload the editor with my previous values by passing it in the components prop, all my ID's are changed.
Is there a way to prevent this?
Like, only change ID's for newly added blocks and not imported code or existing code?
I tried searching but could not see an option.
Thanks!
Answers (3)
@simplecommerce new release published
Anyone have any idea for this issue?
My issue happens when I use for example, bootstrap tabs, in order to make them work and load the right tab, it uses the ID, but since the ID is being regenerated when I load the editor with my components again (for editing), the tabs no longer work, since all ID are replaced and incremented.
Initial drag and drop.
<div tabs-container="" id="iqwah">
<ul role="tablist" class="nav nav-tabs">
<li class="nav-item">
<a id="home-tab-3" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true" class="nav-link active">Tab 1</a>
</li>
<li class="nav-item">
<a id="profile-tab-3" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false" class="nav-link">Tab 2</a>
</li>
<li class="nav-item">
<a id="contact-tab-3" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false" class="nav-link">Tab 3</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade show active" id="home-3" aria-labelledby="home-tab">
</div>
<div role="tabpanel" class="tab-pane fade" id="profile-3" aria-labelledby="profile-tab">
</div>
<div role="tabpanel" class="tab-pane fade" id="contact-3" aria-labelledby="contact-tab">
</div>
</div>
</div>
Reload
<div tabs-container="" id="iqwah">
<ul role="tablist" class="nav nav-tabs">
<li class="nav-item">
<a id="home-tab-3" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true" class="nav-link active">Tab 1</a>
</li>
<li class="nav-item">
<a id="profile-tab-3" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false" class="nav-link">Tab 2</a>
</li>
<li class="nav-item">
<a id="contact-tab-3" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false" class="nav-link">Tab 3</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade show active" id="home-3" aria-labelledby="home-tab">
</div>
<div role="tabpanel" class="tab-pane fade" id="profile-3" aria-labelledby="profile-tab">
</div>
<div role="tabpanel" class="tab-pane fade" id="contact-3" aria-labelledby="contact-tab">
</div>
</div>
</div>
As you can see, my id's have changed.
same issue here.if i have use that id in code, id change when(id-2) reload template to grapejs (auto added "-2" to my id) , if i dont use that id in any part of my code, is fine, id wont change
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1960
[QUESTION] Dynamic class generation with a template
Hi there ! I am wondering if there is a way to force the dynamic class generation (of the form cXXXXX which happens when I drag'n'drop a co...
Issue #905
[Question] need to find nessesary event.
Hello to all! When dragging block into canvas, and drop it: ... we have an event to detect, what block we drop in. ?: but when i drop block...
Issue #951
[QUESTION] Selection of custom components not possible from canvas.
Hey, I tried to figure this out by myself, but I'm feeling I'm going a little bit in circles. So I hope you will have some time to read thi...
Issue #1907
[QUESTION]: Drag and drop external html to editor ?
I have created a component which is heading and a block element for it. I have set the draggable property to be section html element. If I...
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.