Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HTML are not rendered using addWidget in version 12.1.1 #3042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zulfikar4568 opened this issue Apr 30, 2025 · 2 comments
Closed

HTML are not rendered using addWidget in version 12.1.1 #3042

zulfikar4568 opened this issue Apr 30, 2025 · 2 comments

Comments

@zulfikar4568
Copy link

Subject of the issue

It seems HTML is not rendered using addWidget because it was in previous work, or maybe there's a wrong configuration.

Your environment

  • node v22.15.0
  • gridstack 12.1.1
  • browser chrome

Steps to reproduce

grid = GridStack.init({
      float: false,
      cellHeight: '70px',
      minRow: 24,
      removable: '.option-dashboard-trash',
      disableDrag: true,
      acceptWidgets: true,
    });

    grid.addWidget({
      content: '<h1>Hi test</h1>',
    });
Image

Expected behavior

Html it should be rendered

@adumesny
Copy link
Member

@Murphybro2
Copy link

Murphybro2 commented May 9, 2025

If the ability to render html from a string isn't available anymore, do we need to create the parent div html ourselves for each widget we add? Like so:

const el = $(`
  <div class="grid-stack-item" gs-x="1" gs-y="1" gs-w="3" gs-h="3">
    <div class="grid-stack-item-content">
      <b>test bold</b>
    </div>
  </div>
`)[0];
grid.makeWidget(el);

Also, is this has been removed for security reasons, then what is the recommended way of dynamically adding widgets with html content? Is it to add the html to the page and then use makeWidget with an identifier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants