Skip to content

How to define sub-grid in HTML and initialize it later in JS #2554

Open
@vmihailenco

Description

@vmihailenco

I am trying to initialize a sub-grid from HTML attributes, but can't find many examples except this one.

I am trying something like this (https://jsfiddle.net/0wvsym1j/2/):

<div class="grid-stack" id="gs">
  <div gs-w="6" gs-h="4" gs-auto-position="true" class="grid-stack-item grid-stack-sub-grid">
    <div class="grid-stack-item-content">
      <div class="grid-stack grid-stack-nested">
        <div gs-w="3" gs-h="2" gs-auto-position="true" class="grid-stack-item">
          <div class="grid-stack-item-content">
            <div>
              Subgrid
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

And then initialize it separately:

let grid = GridStack.init(options, '#gs')
let subgrids = GridStack.initAll({
    ...options,
    column: 'auto',
  },
  '.grid-stack-nested'
)

Could someone suggest a proper way?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions