Skip to content

Commit f111350

Browse files
committed
fix: use window.Popover (NetBox global) and manually init CSS grid popovers
NetBox exports window.Popover (not window.bootstrap.Popover) so the guard was failing silently. Also add explicit DOMContentLoaded init loop for CSS grid path since NetBox has no auto-init for popovers.
1 parent be54797 commit f111350

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

netbox_device_view/templates/netbox_device_view/deviceview.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@
176176
g.setAttribute("data-bs-content", popContent);
177177
var svgTitle = g.querySelector("title");
178178
if (svgTitle) svgTitle.textContent = p.name;
179-
if (typeof bootstrap !== "undefined" && bootstrap.Popover) {
180-
new bootstrap.Popover(g, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
179+
if (typeof Popover !== "undefined") {
180+
new Popover(g, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
181181
}
182182
});
183183
});
@@ -203,4 +203,13 @@ <h4>Options</h4>
203203
</form>
204204
</div>
205205
</div>
206+
{% if not use_svg %}
207+
<script>
208+
document.addEventListener("DOMContentLoaded", function () {
209+
document.querySelectorAll('.device-view-port[data-bs-toggle="popover"]').forEach(function (el) {
210+
new Popover(el, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
211+
});
212+
});
213+
</script>
214+
{% endif %}
206215
{% endblock %}

netbox_device_view/templates/netbox_device_view/ports.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ <h2 class="card-header">Deviceview {% if object.virtual_chassis %}{{ object.virt
171171
g.setAttribute("data-bs-content", popContent);
172172
var svgTitle = g.querySelector("title");
173173
if (svgTitle) svgTitle.textContent = p.name;
174-
if (typeof bootstrap !== "undefined" && bootstrap.Popover) {
175-
new bootstrap.Popover(g, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
174+
if (typeof Popover !== "undefined") {
175+
new Popover(g, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
176176
}
177177
});
178178
});
@@ -184,4 +184,13 @@ <h2 class="card-header">Deviceview {% if object.virtual_chassis %}{{ object.virt
184184
})();
185185
</script>
186186
{% endif %}
187+
{% if not use_svg %}
188+
<script>
189+
document.addEventListener("DOMContentLoaded", function () {
190+
document.querySelectorAll('.device-view-port[data-bs-toggle="popover"]').forEach(function (el) {
191+
new Popover(el, { trigger: "hover focus", html: true, container: "body", delay: { show: 200, hide: 300 } });
192+
});
193+
});
194+
</script>
195+
{% endif %}
187196
{% endblock %}

0 commit comments

Comments
 (0)