Fix scripts not running in widgets
This commit is contained in:
parent
95f00eface
commit
996463b869
|
@ -22,7 +22,7 @@
|
||||||
<script defer src="{% static 'js/htmx.min.js' %}" integrity="sha384-cZuAZ+ZbwkNRnrKi05G/fjBX+azI9DNOkNYysZ0I/X5ZFgsmMiBXgDZof30F5ofc" crossorigin="anonymous"></script>
|
<script defer src="{% static 'js/htmx.min.js' %}" integrity="sha384-cZuAZ+ZbwkNRnrKi05G/fjBX+azI9DNOkNYysZ0I/X5ZFgsmMiBXgDZof30F5ofc" crossorigin="anonymous"></script>
|
||||||
<script defer src="{% static 'js/remove-me.js' %}" integrity="sha384-6fHcFNoQ8QEI3ZDgw9Z/A6Brk64gF7AnFbLgdrumo8/kBbsKQ/wo7wPegj5WkzuG" crossorigin="anonymous"></script>
|
<script defer src="{% static 'js/remove-me.js' %}" integrity="sha384-6fHcFNoQ8QEI3ZDgw9Z/A6Brk64gF7AnFbLgdrumo8/kBbsKQ/wo7wPegj5WkzuG" crossorigin="anonymous"></script>
|
||||||
<script defer src="{% static 'js/hyperscript.min.js' %}" integrity="sha384-6GYN8BDHOJkkru6zcpGOUa//1mn+5iZ/MyT6mq34WFIpuOeLF52kSi721q0SsYF9" crossorigin="anonymous"></script>
|
<script defer src="{% static 'js/hyperscript.min.js' %}" integrity="sha384-6GYN8BDHOJkkru6zcpGOUa//1mn+5iZ/MyT6mq34WFIpuOeLF52kSi721q0SsYF9" crossorigin="anonymous"></script>
|
||||||
<script src="{% static 'js/bulma-tagsinput.min.js' %}" integrity="sha384-GmnKCsPJIPPZbNVXpkGRmKdxOa0PQLnOM/hQLIHvMRERySuyvFqKGc76iHTGUY+d" crossorigin="anonymous"></script>
|
<script src="{% static 'js/bulma-tagsinput.min.js' %}"></script>
|
||||||
<script src="{% static 'js/jquery.min.js' %}"></script>
|
<script src="{% static 'js/jquery.min.js' %}"></script>
|
||||||
<script src="{% static 'js/gridstack-all.js' %}"></script>
|
<script src="{% static 'js/gridstack-all.js' %}"></script>
|
||||||
<script defer src="{% static 'js/magnet.min.js' %}"></script>
|
<script defer src="{% static 'js/magnet.min.js' %}"></script>
|
||||||
|
|
|
@ -98,14 +98,16 @@
|
||||||
<script>
|
<script>
|
||||||
//var contents = $("#drilldown-widget").outerHTML;
|
//var contents = $("#drilldown-widget").outerHTML;
|
||||||
var contents = document.getElementById("drilldown-widget");
|
var contents = document.getElementById("drilldown-widget");
|
||||||
|
var scripts = contents.getElementsByTagName("script");
|
||||||
var grid = document.getElementById("grid-stack-main").gridstack;
|
var grid = document.getElementById("grid-stack-main").gridstack;
|
||||||
grid.addWidget(contents.innerHTML);
|
grid.addWidget(contents.innerHTML);
|
||||||
contents.outerHTML = "";
|
contents.outerHTML = "";
|
||||||
//grid.compact();
|
// restore scripts that aren't going to be run
|
||||||
// because we remove the element the JS runs in
|
for (var i = 0; i < scripts.length; i++) {
|
||||||
// so we need to run it again here
|
eval(scripts[i].innerHTML);
|
||||||
// initTabs("{{ unique }}");
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
<script>
|
<script>
|
||||||
|
if (typeof grid != "undefined") {
|
||||||
grid.removeWidget("drilldown-widget-results");
|
grid.removeWidget("drilldown-widget-results");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="drilldown-widget" style="display: none;">
|
<div id="drilldown-widget" style="display: none;">
|
||||||
<div id="drilldown-widget-results" class="grid-stack-item" gs-w="10" gs-h="30" gs-y="10" gs-x="1">
|
<div id="drilldown-widget-results" class="grid-stack-item" gs-w="10" gs-h="30" gs-y="10" gs-x="1">
|
||||||
<div class="grid-stack-item-content">
|
<div class="grid-stack-item-content">
|
||||||
|
@ -53,15 +56,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
console.log("RUNS");
|
if (typeof grid != "undefined") {
|
||||||
//var contents = $("#drilldown-widget").outerHTML;
|
//var contents = $("#drilldown-widget").outerHTML;
|
||||||
var contents = document.getElementById("drilldown-widget");
|
var contents = document.getElementById("drilldown-widget");
|
||||||
|
var scripts = contents.getElementsByTagName("script");
|
||||||
var grid = document.getElementById("grid-stack-main").gridstack;
|
var grid = document.getElementById("grid-stack-main").gridstack;
|
||||||
grid.addWidget(contents.innerHTML);
|
grid.addWidget(contents.innerHTML);
|
||||||
contents.outerHTML = "";
|
contents.outerHTML = "";
|
||||||
// grid.compact();
|
// restore scripts that aren't going to be run
|
||||||
// because we remove the element the JS runs in
|
for (var i = 0; i < scripts.length; i++) {
|
||||||
// so we need to run it again here
|
eval(scripts[i].innerHTML);
|
||||||
// initTabs("{{ unique }}");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue