* 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')
| 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 |
no test coverage detected