bland-coat-6833
09/01/2022, 1:34 PM.class
with htmx, so it's not quite the same as OOBmysterious-toddler-20573
09/01/2022, 1:35 PMbland-coat-6833
09/01/2022, 1:35 PMbland-coat-6833
09/01/2022, 1:37 PMbland-coat-6833
09/01/2022, 1:37 PMbland-coat-6833
09/01/2022, 1:39 PMrapid-optician-10719
09/01/2022, 1:41 PMbland-coat-6833
09/01/2022, 1:41 PMbland-coat-6833
09/01/2022, 1:42 PMrapid-optician-10719
09/01/2022, 1:43 PMtall-river-23601
09/01/2022, 1:43 PMmysterious-toddler-20573
09/01/2022, 1:45 PMworried-hair-75253
09/01/2022, 2:22 PM.addWidget()
call? Here is what I do. I have a hidden DIV as the HTMX Target, then I do this:
let container = htmx.find('#newWidgetTargetContainer');
let widgetelement = container.firstElementChild.cloneNode(true);
container.firstElementChild.remove();
let grid = document.querySelector('.grid-stack').gridstack;
grid.addWidget(widgetelement);
htmx.process(widgetelement);
fierce-application-41107
09/01/2022, 2:23 PMfierce-application-41107
09/01/2022, 2:23 PMfierce-application-41107
09/01/2022, 2:26 PMfierce-application-41107
09/01/2022, 2:27 PMworried-hair-75253
09/01/2022, 2:29 PMwidgetelement
is the entire gridstackItem, not just the innerHTML ... again, basically same thingfierce-application-41107
09/01/2022, 2:30 PMfierce-application-41107
09/01/2022, 2:31 PMfierce-application-41107
09/01/2022, 2:31 PMworried-hair-75253
09/01/2022, 2:32 PMfierce-application-41107
09/01/2022, 2:34 PMfierce-application-41107
09/01/2022, 2:37 PMworried-hair-75253
09/01/2022, 2:39 PMfierce-application-41107
09/01/2022, 2:55 PMdocument.addEventListener('load-widget', function(event) {
grid.removeWidget("drilldown-widget-results");
let container = htmx.find('#drilldown-widget');
var scripts = htmx.findAll(container, "script");
let widgetelement = container.firstElementChild.cloneNode(true);
container.firstElementChild.remove();
//let grid = document.querySelector('.grid-stack').gridstack;
grid.addWidget(widgetelement);
htmx.process(widgetelement);
for (var i = 0; i < scripts.length; i++) {
eval(scripts[i].innerHTML);
}
});
and in the widget:
var widget_event = new Event('load-widget');
document.dispatchEvent(widget_event);
fierce-application-41107
09/01/2022, 2:55 PMfierce-application-41107
09/01/2022, 2:55 PMfierce-application-41107
09/01/2022, 2:55 PMfierce-application-41107
09/01/2022, 2:56 PM