MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / createDiv

Method createDiv

src/utils.ts:206–211  ·  view source on GitHub ↗

* Create a div element with the specified CSS classes. * * @param classes array of CSS class names to add * @param parent optional parent element to append the div to * @returns the created div element * * @example * const div = Utils.createDiv(['grid-item', 'draggable']); *

(classes: string[], parent?: HTMLElement)

Source from the content-addressed store, hash-verified

204 * const nested = Utils.createDiv(['content'], parentDiv);
205 */
206 static createDiv(classes: string[], parent?: HTMLElement): HTMLElement {
207 const el = document.createElement('div');
208 classes.forEach(c => {if (c) el.classList.add(c)});
209 parent?.appendChild(el);
210 return el;
211 }
212
213 /**
214 * Check if a widget should resize to fit its content.

Callers 5

addGridMethod · 0.80
placeholderMethod · 0.80
createWidgetDivsMethod · 0.80
makeSubGridMethod · 0.80
utils-spec.tsFile · 0.80

Calls 1

addMethod · 0.45

Tested by

no test coverage detected