@@ -965,19 +965,22 @@ export class GridStack {
965965 }
966966
967967 /**
968- * If you add elements to your grid by hand, you have to tell gridstack afterwards to make them widgets.
968+ * If you add elements to your grid by hand (or have some framework creating DOM) , you have to tell gridstack afterwards to make them widgets.
969969 * If you want gridstack to add the elements for you, use `addWidget()` instead.
970970 * Makes the given element a widget and returns it.
971971 * @param els widget or single selector to convert.
972+ * @param options widget definition to use instead of reading attributes or using default sizing values
972973 *
973974 * @example
974975 * let grid = GridStack.init();
975- * grid.el.appendChild('<div id="gsi-1" gs-w="3"></div>');
976- * grid.makeWidget('#gsi-1');
976+ * grid.el.appendChild('<div id="1" gs-w="3"></div>');
977+ * grid.el.appendChild('<div id="2"></div>');
978+ * grid.makeWidget('1');
979+ * grid.makeWidget('2', {w:2, content: 'hello'});
977980 */
978- public makeWidget ( els : GridStackElement ) : GridItemHTMLElement {
981+ public makeWidget ( els : GridStackElement , options ?: GridStackWidget ) : GridItemHTMLElement {
979982 let el = GridStack . getElement ( els ) ;
980- this . _prepareElement ( el , true ) ;
983+ this . _prepareElement ( el , true , options ) ;
981984 this . _updateContainerHeight ( ) ;
982985 this . _triggerAddEvent ( ) ;
983986 this . _triggerChangeEvent ( ) ;
@@ -1072,6 +1075,10 @@ export class GridStack {
10721075 }
10731076 if ( ! node ) return ;
10741077
1078+ if ( GridStack . addRemoveCB ) {
1079+ GridStack . addRemoveCB ( this . el , node , false , false ) ;
1080+ }
1081+
10751082 // remove our DOM data (circular link) and drag&drop permanently
10761083 delete el . gridstackNode ;
10771084 this . _removeDD ( el ) ;
0 commit comments