Issue #1875Opened March 10, 2019by simplecommerce1 reactions

[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)

artfMarch 24, 20191 reactions

@simplecommerce new release published

simplecommerceMarch 15, 20190 reactions

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.

sbiwaichoonMarch 16, 20190 reactions

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.

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.