Skip to content

Snippets / JS

JS

Trigger Voxel Popup for Any Action

D Donald McGuinn · 400 views · Updated 2 years ago
This will trigger the login pop up for whatever action you want or button click 
Add the class “click-to-login” to whatever button or container
document.addEventListener('DOMContentLoaded', function () {
// Find all containers with the class "click-to-login"
var containers = document.querySelectorAll('.click-to-login');

// Add click event listener for each container
containers.forEach(function (container) {
container.addEventListener('click', function (event) {
// Prevent default behavior
event.preventDefault();

// Call the Voxel.requireAuth function or any other custom action
Voxel.requireAuth(event);

// Additional custom actions can be added here
});
});
});
JS · 17 lines

Discussion

Ask a question or share how you used this.

Log in to join the discussion.

No comments yet — be the first.

Voxel Guide assistant
Ask about snippets, addons & how-tos

Hey — how can I help?

I can dig through the library for snippets, addons, and tutorials.

AI can be wrong — double-check anything important.