mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
16 lines
412 B
TypeScript
16 lines
412 B
TypeScript
import { isTruthy, getElements } from './util';
|
|
|
|
/**
|
|
* Allow any element to be made "clickable" with the use of the `data-href` attribute.
|
|
*/
|
|
export function initLinks(): void {
|
|
for (const link of getElements('*[data-href]')) {
|
|
const href = link.getAttribute('data-href');
|
|
if (isTruthy(href)) {
|
|
link.addEventListener('click', () => {
|
|
window.location.assign(href);
|
|
});
|
|
}
|
|
}
|
|
}
|