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

Method initAll

src/gridstack.ts:119–133  ·  view source on GitHub ↗

* Will initialize a list of elements (given a selector) and return an array of grids. * @param options grid options (optional) * @param selector elements selector to convert to grids (default to '.grid-stack' class selector) * * @example * const grids = GridStack.initAll(); * grids

(options: GridStackOptions = {}, selector = '.grid-stack')

Source from the content-addressed store, hash-verified

117 * grids.forEach(...)
118 */
119 public static initAll(options: GridStackOptions = {}, selector = '.grid-stack'): GridStack[] {
120 const grids: GridStack[] = [];
121 if (typeof document === 'undefined') return grids; // temp workaround SSR
122 GridStack.getGridElements(selector).forEach(el => {
123 if (!el.gridstack) {
124 el.gridstack = new GridStack(el, Utils.cloneDeep(options));
125 }
126 grids.push(el.gridstack);
127 });
128 if (grids.length === 0) {
129 console.error('GridStack.initAll() no grid was found with selector "' + selector + '" - element missing or wrong selector ?' +
130 '\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.');
131 }
132 return grids;
133 }
134
135 /**
136 * call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then

Callers 1

gridstack-spec.tsFile · 0.80

Calls 2

getGridElementsMethod · 0.80
cloneDeepMethod · 0.80

Tested by

no test coverage detected