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

Method init

src/gridstack.ts:92–108  ·  view source on GitHub ↗

* initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will * simply return the existing instance (ignore any passed options). There is also an initAll() version that support * multiple grids initialization at once. Or you can use addGrid() to c

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

Source from the content-addressed store, hash-verified

90 * const grid = document.querySelector('.grid-stack').gridstack;
91 */
92 public static init(options: GridStackOptions = {}, elOrString: GridStackElement = '.grid-stack'): GridStack {
93 if (typeof document === 'undefined') return null; // temp workaround SSR
94 const el = GridStack.getGridElement(elOrString);
95 if (!el) {
96 if (typeof elOrString === 'string') {
97 console.error('GridStack.initAll() no grid was found with selector "' + elOrString + '" - element missing or wrong selector ?' +
98 '\nNote: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.');
99 } else {
100 console.error('GridStack.init() no grid element was passed.');
101 }
102 return null;
103 }
104 if (!el.gridstack) {
105 el.gridstack = new GridStack(el, Utils.cloneDeep(options));
106 }
107 return el.gridstack
108 }
109
110 /**
111 * Will initialize a list of elements (given a selector) and return an array of grids.

Callers 11

GridStackRenderProviderFunction · 0.45
ngOnInitMethod · 0.45
ngOnInitMethod · 0.45
ngAfterViewInitMethod · 0.45
ngAfterViewInitMethod · 0.45
addGridMethod · 0.45
_getDDElementsMethod · 0.45
gridstack-spec.tsFile · 0.45
regression-spec.tsFile · 0.45

Calls 2

getGridElementMethod · 0.80
cloneDeepMethod · 0.80

Tested by

no test coverage detected